|
@@ -657,7 +657,8 @@ int fix_actions(struct action* a)
|
|
if (tmp==0){
|
|
if (tmp==0){
|
|
LOG(L_CRIT, "ERROR: fix_actions:"
|
|
LOG(L_CRIT, "ERROR: fix_actions:"
|
|
"memory allocation failure\n");
|
|
"memory allocation failure\n");
|
|
- return E_OUT_OF_MEM;
|
|
|
|
|
|
+ ret = E_OUT_OF_MEM;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
t->val[0].type=STRING_ST;
|
|
t->val[0].type=STRING_ST;
|
|
t->val[0].u.string=tmp;
|
|
t->val[0].u.string=tmp;
|
|
@@ -666,7 +667,7 @@ int fix_actions(struct action* a)
|
|
s.s = t->val[0].u.string;
|
|
s.s = t->val[0].u.string;
|
|
s.len = strlen(s.s);
|
|
s.len = strlen(s.s);
|
|
p=add_proxy(&s, t->val[1].u.number, 0); /* FIXME proto*/
|
|
p=add_proxy(&s, t->val[1].u.number, 0); /* FIXME proto*/
|
|
- if (p==0) return E_BAD_ADDRESS;
|
|
|
|
|
|
+ if (p==0) { ret =E_BAD_ADDRESS; goto error; }
|
|
t->val[0].u.data=p;
|
|
t->val[0].u.data=p;
|
|
t->val[0].type=PROXY_ST;
|
|
t->val[0].type=PROXY_ST;
|
|
break;
|
|
break;
|
|
@@ -676,7 +677,8 @@ int fix_actions(struct action* a)
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid type"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid type"
|
|
"%d (should be string or number)\n",
|
|
"%d (should be string or number)\n",
|
|
t->type);
|
|
t->type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case IF_T:
|
|
case IF_T:
|
|
@@ -684,19 +686,22 @@ int fix_actions(struct action* a)
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for if (should be rval expr)\n",
|
|
"%d for if (should be rval expr)\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}else if( (t->val[1].type!=ACTIONS_ST) &&
|
|
}else if( (t->val[1].type!=ACTIONS_ST) &&
|
|
(t->val[1].type!=NOSUBTYPE) ){
|
|
(t->val[1].type!=NOSUBTYPE) ){
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for if() {...} (should be action)\n",
|
|
"%d for if() {...} (should be action)\n",
|
|
t->val[1].type);
|
|
t->val[1].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}else if( (t->val[2].type!=ACTIONS_ST) &&
|
|
}else if( (t->val[2].type!=ACTIONS_ST) &&
|
|
(t->val[2].type!=NOSUBTYPE) ){
|
|
(t->val[2].type!=NOSUBTYPE) ){
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for if() {} else{...}(should be action)\n",
|
|
"%d for if() {} else{...}(should be action)\n",
|
|
t->val[2].type);
|
|
t->val[2].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
rve=(struct rval_expr*)t->val[0].u.data;
|
|
rve=(struct rval_expr*)t->val[0].u.data;
|
|
if (rve){
|
|
if (rve){
|
|
@@ -715,7 +720,8 @@ int fix_actions(struct action* a)
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
"(%d,%d): type mismatch?",
|
|
"(%d,%d): type mismatch?",
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
- return E_UNSPEC;
|
|
|
|
|
|
+ ret = E_UNSPEC;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
/* it's not an error anymore to have non-int in an if,
|
|
/* it's not an error anymore to have non-int in an if,
|
|
only a script warning (to allow backward compat. stuff
|
|
only a script warning (to allow backward compat. stuff
|
|
@@ -728,16 +734,16 @@ int fix_actions(struct action* a)
|
|
}
|
|
}
|
|
*/
|
|
*/
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ( (t->val[1].type==ACTIONS_ST)&&(t->val[1].u.data) ){
|
|
if ( (t->val[1].type==ACTIONS_ST)&&(t->val[1].u.data) ){
|
|
if ((ret=fix_actions((struct action*)t->val[1].u.data))<0)
|
|
if ((ret=fix_actions((struct action*)t->val[1].u.data))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ( (t->val[2].type==ACTIONS_ST)&&(t->val[2].u.data) ){
|
|
if ( (t->val[2].type==ACTIONS_ST)&&(t->val[2].u.data) ){
|
|
if ((ret=fix_actions((struct action*)t->val[2].u.data))
|
|
if ((ret=fix_actions((struct action*)t->val[2].u.data))
|
|
<0)
|
|
<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case SWITCH_T:
|
|
case SWITCH_T:
|
|
@@ -745,35 +751,40 @@ int fix_actions(struct action* a)
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for switch() (should be expr)\n",
|
|
"%d for switch() (should be expr)\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}else if (t->val[1].type!=CASE_ST){
|
|
}else if (t->val[1].type!=CASE_ST){
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for switch(...){...}(should be case)\n",
|
|
"%d for switch(...){...}(should be case)\n",
|
|
t->val[1].type);
|
|
t->val[1].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if (t->val[0].u.data){
|
|
if (t->val[0].u.data){
|
|
if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
|
|
if ((ret=fix_rval_expr(&t->val[0].u.data))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}else{
|
|
}else{
|
|
LOG(L_CRIT, "BUG: fix_actions: null switch()"
|
|
LOG(L_CRIT, "BUG: fix_actions: null switch()"
|
|
" expression\n");
|
|
" expression\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ((ret=fix_switch(t))<0)
|
|
if ((ret=fix_switch(t))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
case WHILE_T:
|
|
case WHILE_T:
|
|
if (t->val[0].type!=RVE_ST){
|
|
if (t->val[0].type!=RVE_ST){
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for while() (should be expr)\n",
|
|
"%d for while() (should be expr)\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}else if (t->val[1].type!=ACTIONS_ST){
|
|
}else if (t->val[1].type!=ACTIONS_ST){
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for while(...){...}(should be action)\n",
|
|
"%d for while(...){...}(should be action)\n",
|
|
t->val[1].type);
|
|
t->val[1].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
rve=(struct rval_expr*)t->val[0].u.data;
|
|
rve=(struct rval_expr*)t->val[0].u.data;
|
|
if (rve){
|
|
if (rve){
|
|
@@ -792,24 +803,27 @@ int fix_actions(struct action* a)
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
"(%d,%d): type mismatch?",
|
|
"(%d,%d): type mismatch?",
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
- return E_UNSPEC;
|
|
|
|
|
|
+ ret = E_UNSPEC;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if (rve_type!=RV_INT && rve_type!=RV_NONE){
|
|
if (rve_type!=RV_INT && rve_type!=RV_NONE){
|
|
LOG(L_ERR, "fix_actions: invalid expression (%d,%d):"
|
|
LOG(L_ERR, "fix_actions: invalid expression (%d,%d):"
|
|
" bad type, integer expected\n",
|
|
" bad type, integer expected\n",
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
- return E_UNSPEC;
|
|
|
|
|
|
+ ret = E_UNSPEC;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}else{
|
|
}else{
|
|
LOG(L_CRIT, "BUG: fix_actions: null while()"
|
|
LOG(L_CRIT, "BUG: fix_actions: null while()"
|
|
" expression\n");
|
|
" expression\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ( t->val[1].u.data &&
|
|
if ( t->val[1].u.data &&
|
|
((ret= fix_actions((struct action*)t->val[1].u.data))<0)){
|
|
((ret= fix_actions((struct action*)t->val[1].u.data))<0)){
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case DROP_T:
|
|
case DROP_T:
|
|
@@ -833,20 +847,23 @@ int fix_actions(struct action* a)
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
LOG(L_ERR, "fix_actions: invalid expression "
|
|
"(%d,%d): type mismatch?",
|
|
"(%d,%d): type mismatch?",
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
- return E_UNSPEC;
|
|
|
|
|
|
+ ret = E_UNSPEC;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if (rve_type!=RV_INT && rve_type!=RV_NONE){
|
|
if (rve_type!=RV_INT && rve_type!=RV_NONE){
|
|
LOG(L_ERR, "fix_actions: invalid expression (%d,%d):"
|
|
LOG(L_ERR, "fix_actions: invalid expression (%d,%d):"
|
|
" bad type, integer expected\n",
|
|
" bad type, integer expected\n",
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
rve->fpos.s_line, rve->fpos.s_col);
|
|
- return E_UNSPEC;
|
|
|
|
|
|
+ ret = E_UNSPEC;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
if ((ret=fix_rval_expr((void**)&rve))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}else{
|
|
}else{
|
|
LOG(L_CRIT, "BUG: fix_actions: null drop/return"
|
|
LOG(L_CRIT, "BUG: fix_actions: null drop/return"
|
|
" expression\n");
|
|
" expression\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
case ASSIGN_T:
|
|
case ASSIGN_T:
|
|
@@ -854,12 +871,14 @@ int fix_actions(struct action* a)
|
|
if (t->val[0].type !=LVAL_ST) {
|
|
if (t->val[0].type !=LVAL_ST) {
|
|
LOG(L_CRIT, "BUG: fix_actions: Invalid left side of"
|
|
LOG(L_CRIT, "BUG: fix_actions: Invalid left side of"
|
|
" assignment\n");
|
|
" assignment\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
if (t->val[1].type !=RVE_ST) {
|
|
if (t->val[1].type !=RVE_ST) {
|
|
LOG(L_CRIT, "BUG: fix_actions: Invalid right side of"
|
|
LOG(L_CRIT, "BUG: fix_actions: Invalid right side of"
|
|
" assignment (%d)\n", t->val[1].type);
|
|
" assignment (%d)\n", t->val[1].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
lval=t->val[0].u.data;
|
|
lval=t->val[0].u.data;
|
|
if (lval->type==LV_AVP){
|
|
if (lval->type==LV_AVP){
|
|
@@ -867,16 +886,18 @@ int fix_actions(struct action* a)
|
|
LOG(L_ERR, "ERROR: You cannot change domain"
|
|
LOG(L_ERR, "ERROR: You cannot change domain"
|
|
" attributes from the script, they are"
|
|
" attributes from the script, they are"
|
|
" read-only\n");
|
|
" read-only\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
} else if (lval->lv.avps.type & AVP_CLASS_GLOBAL) {
|
|
} else if (lval->lv.avps.type & AVP_CLASS_GLOBAL) {
|
|
LOG(L_ERR, "ERROR: You cannot change global"
|
|
LOG(L_ERR, "ERROR: You cannot change global"
|
|
" attributes from the script, they are"
|
|
" attributes from the script, they are"
|
|
"read-only\n");
|
|
"read-only\n");
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if ((ret=fix_rval_expr(&t->val[1].u.data))<0)
|
|
if ((ret=fix_rval_expr(&t->val[1].u.data))<0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
break;
|
|
break;
|
|
|
|
|
|
case MODULE_T:
|
|
case MODULE_T:
|
|
@@ -891,7 +912,7 @@ int fix_actions(struct action* a)
|
|
if (t->val[1].u.number==0) {
|
|
if (t->val[1].u.number==0) {
|
|
ret = cmd->c.fixup(0, 0);
|
|
ret = cmd->c.fixup(0, 0);
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
/* type cast NUMBER to STRING, old modules may expect
|
|
/* type cast NUMBER to STRING, old modules may expect
|
|
* all STRING params during fixup */
|
|
* all STRING params during fixup */
|
|
@@ -904,7 +925,8 @@ int fix_actions(struct action* a)
|
|
if (!t->val[i+2].u.string) {
|
|
if (!t->val[i+2].u.string) {
|
|
LOG(L_CRIT, "ERROR: cannot translate NUMBER"
|
|
LOG(L_CRIT, "ERROR: cannot translate NUMBER"
|
|
" to STRING\n");
|
|
" to STRING\n");
|
|
- return E_OUT_OF_MEM;
|
|
|
|
|
|
+ ret = E_OUT_OF_MEM;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
strcpy(t->val[i+2].u.string, buf);
|
|
strcpy(t->val[i+2].u.string, buf);
|
|
t->val[i+2].type = STRING_ST;
|
|
t->val[i+2].type = STRING_ST;
|
|
@@ -917,7 +939,7 @@ int fix_actions(struct action* a)
|
|
if (t->val[i+2].u.data != p)
|
|
if (t->val[i+2].u.data != p)
|
|
t->val[i+2].type = MODFIXUP_ST;
|
|
t->val[i+2].type = MODFIXUP_ST;
|
|
if (ret < 0)
|
|
if (ret < 0)
|
|
- return ret;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
@@ -926,7 +948,8 @@ int fix_actions(struct action* a)
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for force_send_socket\n",
|
|
"%d for force_send_socket\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
he=resolvehost(
|
|
he=resolvehost(
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name
|
|
@@ -935,7 +958,8 @@ int fix_actions(struct action* a)
|
|
LOG(L_ERR, "ERROR: fix_actions: force_send_socket:"
|
|
LOG(L_ERR, "ERROR: fix_actions: force_send_socket:"
|
|
" could not resolve %s\n",
|
|
" could not resolve %s\n",
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name);
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name);
|
|
- return E_BAD_ADDRESS;
|
|
|
|
|
|
+ ret = E_BAD_ADDRESS;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
hostent2ip_addr(&ip, he, 0);
|
|
hostent2ip_addr(&ip, he, 0);
|
|
si=find_si(&ip, ((struct socket_id*)t->val[0].u.data)->port,
|
|
si=find_si(&ip, ((struct socket_id*)t->val[0].u.data)->port,
|
|
@@ -945,7 +969,8 @@ int fix_actions(struct action* a)
|
|
" argument: %s:%d (ser doesn't listen on it)\n",
|
|
" argument: %s:%d (ser doesn't listen on it)\n",
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name,
|
|
((struct socket_id*)t->val[0].u.data)->addr_lst->name,
|
|
((struct socket_id*)t->val[0].u.data)->port);
|
|
((struct socket_id*)t->val[0].u.data)->port);
|
|
- return E_BAD_ADDRESS;
|
|
|
|
|
|
+ ret = E_BAD_ADDRESS;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
t->val[0].u.data=si;
|
|
t->val[0].u.data=si;
|
|
t->val[0].type=SOCKETINFO_ST;
|
|
t->val[0].type=SOCKETINFO_ST;
|
|
@@ -955,7 +980,8 @@ int fix_actions(struct action* a)
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
LOG(L_CRIT, "BUG: fix_actions: invalid subtype"
|
|
"%d for udp_mtu_try_proto\n",
|
|
"%d for udp_mtu_try_proto\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
switch(t->val[0].u.number){
|
|
switch(t->val[0].u.number){
|
|
case PROTO_UDP:
|
|
case PROTO_UDP:
|
|
@@ -980,7 +1006,8 @@ int fix_actions(struct action* a)
|
|
if (t->val[0].type!=STRING_ST){
|
|
if (t->val[0].type!=STRING_ST){
|
|
BUG("invalid subtype%d for append_branch_t\n",
|
|
BUG("invalid subtype%d for append_branch_t\n",
|
|
t->val[0].type);
|
|
t->val[0].type);
|
|
- return E_BUG;
|
|
|
|
|
|
+ ret = E_BUG;
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
s.s=t->val[0].u.string;
|
|
s.s=t->val[0].u.string;
|
|
s.len=(s.s)?strlen(s.s):0;
|
|
s.len=(s.s)?strlen(s.s):0;
|
|
@@ -993,6 +1020,10 @@ int fix_actions(struct action* a)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return 0;
|
|
return 0;
|
|
|
|
+
|
|
|
|
+error:
|
|
|
|
+ LM_ERR("fixing failed (code=%d) at cfg line %d\n", ret, t->cline);
|
|
|
|
+ return ret;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|