Skip to content

Commit

Permalink
Fix finding the script functions in assigments.
Browse files Browse the repository at this point in the history
Do an aggressive search by digging through all possible ACTIONS or EXPRessions to see if a function is used in the script.
Fix for #1022

(cherry picked from commit 87a3a41)
  • Loading branch information
bogdan-iancu committed Jan 25, 2017
1 parent 2671186 commit c44264e
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions route_struct.c
Expand Up @@ -650,34 +650,42 @@ int is_mod_func_used(struct action *a, char *name, int param_no)
if (a->type==MODULE_T) {
/* first param is the name of the function */
cmd = (cmd_export_t*)a->elem[0].u.data;
LM_DBG("reached to <%s>\n",cmd->name);
if (strcasecmp(cmd->name, name)==0 &&
(param_no==cmd->param_no || param_no==-1) ) {
LM_DBG("function %s found to be used in script\n",name);
return 1;
}
}

if (a->type==IF_T || a->type==WHILE_T)
/* follow all leads from actions/expressions than may have
* sub-blocks of instructions */
if (a->elem[0].type==ACTIONS_ST)
if (is_mod_func_used((struct action*)a->elem[0].u.data,
name,param_no)==1)
return 1;
if (a->elem[0].type==EXPR_ST)
if (is_mod_func_in_expr((struct expr*)a->elem[0].u.data,
name,param_no)==1)
return 1;

/* follow all leads from actions than may have
* sub-blocks of instructions */
if (a->elem[0].type==ACTIONS_ST)
if (is_mod_func_used((struct action*)a->elem[0].u.data,
name,param_no)==1)
return 1;

if (a->elem[1].type==ACTIONS_ST)
if (is_mod_func_used((struct action*)a->elem[1].u.data,
name,param_no)==1)
return 1;
if (is_mod_func_used((struct action*)a->elem[1].u.data,
name,param_no)==1)
return 1;
if (a->elem[1].type==EXPR_ST)
if (is_mod_func_in_expr((struct expr*)a->elem[1].u.data,
name,param_no)==1)
return 1;

if (a->elem[2].type==ACTIONS_ST)
if (is_mod_func_used((struct action*)a->elem[2].u.data,
name,param_no)==1)
return 1;
if (is_mod_func_used((struct action*)a->elem[2].u.data,
name,param_no)==1)
return 1;
if (a->elem[2].type==EXPR_ST)
if (is_mod_func_in_expr((struct expr*)a->elem[2].u.data,
name,param_no)==1)
return 1;

a = a->next;
}
Expand Down

0 comments on commit c44264e

Please sign in to comment.