check to see if a comma or an open paren came first when splitting the application

from the application arguments (bug )


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5721 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Russell Bryant 20 years ago
parent 9d0a1ce4a8
commit 364e179b78

@ -1619,7 +1619,7 @@ static int pbx_load_module(void)
struct ast_variable *v; struct ast_variable *v;
char *cxt, *ext, *pri, *appl, *data, *tc, *cidmatch; char *cxt, *ext, *pri, *appl, *data, *tc, *cidmatch;
struct ast_context *con; struct ast_context *con;
char *start, *end; char *end;
char *label; char *label;
char realvalue[256]; char realvalue[256];
int lastpri = -2; int lastpri = -2;
@ -1656,7 +1656,7 @@ static int pbx_load_module(void)
char *stringp=NULL; char *stringp=NULL;
int ipri = -2; int ipri = -2;
char realext[256]=""; char realext[256]="";
char *plus; char *plus, *firstp, *firstc;
tc = strdup(v->value); tc = strdup(v->value);
if(tc!=NULL){ if(tc!=NULL){
stringp=tc; stringp=tc;
@ -1711,25 +1711,28 @@ static int pbx_load_module(void)
appl = stringp; appl = stringp;
if (!appl) if (!appl)
appl=""; appl="";
if (!(start = strchr(appl, '('))) { /* Find the first occurrence of either '(' or ',' */
if (stringp) firstc = strchr(appl, ',');
appl = strsep(&stringp, ","); firstp = strchr(appl, '(');
else if (firstc && ((!firstp) || (firstc < firstp))) {
appl = ""; /* comma found, no parenthesis */
} /* or both found, but comma found first */
if (start && (end = strrchr(appl, ')'))) { appl = strsep(&stringp, ",");
*start = *end = '\0'; data = stringp;
data = start + 1; } else if ((!firstc) && (!firstp)) {
process_quotes_and_slashes(data, ',', '|'); /* Neither found */
} else if (stringp!=NULL && *stringp=='"') { data = "";
stringp++;
data = strsep(&stringp, "\"");
stringp++;
} else { } else {
if (stringp) /* Final remaining case is parenthesis found first */
data = strsep(&stringp, ","); appl = strsep(&stringp, "(");
else data = stringp;
data = ""; end = strrchr(data, ')');
if ((end = strrchr(data, ')'))) {
*end = '\0';
} else {
ast_log(LOG_WARNING, "No closing parenthesis found? '%s(%s'\n", appl, data);
}
process_quotes_and_slashes(data, ',', '|');
} }
if (!data) if (!data)

Loading…
Cancel
Save