pbx.c: Properly parse labels with leading digits
authorSean Bright <sean.bright@gmail.com>
Thu, 11 Apr 2019 17:49:38 +0000 (13:49 -0400)
committerSean Bright <sean.bright@gmail.com>
Thu, 11 Apr 2019 18:38:03 +0000 (12:38 -0600)
If the target of a Goto is a label that starts with a number, we
erroneously treat the leading digits as a priority.

ASTERISK-20182 #close
Reported by: Janu

Change-Id: Ia78408c0805a729103917247ecfc802f6fafc94b

main/pbx.c

index ee5ed7e..4a83453 100644 (file)
@@ -8760,6 +8760,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
        char *stringp;
        int ipri;
        int mode = 0;
        char *stringp;
        int ipri;
        int mode = 0;
+       char rest[2] = "";
 
        if (ast_strlen_zero(goto_string)) {
                ast_log(LOG_WARNING, "Goto requires an argument ([[context,]extension,]priority)\n");
 
        if (ast_strlen_zero(goto_string)) {
                ast_log(LOG_WARNING, "Goto requires an argument ([[context,]extension,]priority)\n");
@@ -8785,7 +8786,7 @@ static int pbx_parseable_goto(struct ast_channel *chan, const char *goto_string,
                mode = -1;
                pri++;
        }
                mode = -1;
                pri++;
        }
-       if (sscanf(pri, "%30d", &ipri) != 1) {
+       if (sscanf(pri, "%30d%1s", &ipri, rest) != 1) {
                ipri = ast_findlabel_extension(chan, context ? context : ast_channel_context(chan),
                        exten ? exten : ast_channel_exten(chan), pri,
                        S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
                ipri = ast_findlabel_extension(chan, context ? context : ast_channel_context(chan),
                        exten ? exten : ast_channel_exten(chan), pri,
                        S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));