]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
pbx_builtin: Properly handle hangup during Background
authorSean Bright <sean.bright@gmail.com>
Wed, 31 May 2017 16:45:45 +0000 (12:45 -0400)
committerSean Bright <sean.bright@gmail.com>
Wed, 31 May 2017 17:22:12 +0000 (13:22 -0400)
Before this patch, when a user hung up during a Background, we would
stuff 0xff into a char and attempt a dialplan lookup of it. This caused
problems for some realtime engines which interpreted the value as the
beginning of an invalid UTF-8 sequence.

ASTERISK-19291 #close
Reported by: Andrew Nowrot

Change-Id: I8ca6da93252d61c76ebdb46a4aa65e73ca985358

main/pbx_builtins.c

index fa155888aecf6d083b695476e783bbe59dfdab8a..605e0c97e6a97af70566f5a5e805ce329e09d0b4 100644 (file)
@@ -1113,6 +1113,13 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
                }
        }
 
+       /* If ast_waitstream didn't give us back a digit, there is nothing else to do */
+       if (res <= 0) {
+               goto done;
+       }
+
+       exten[0] = res;
+
        /*
         * If the single digit DTMF is an extension in the specified context, then
         * go there and signal no DTMF.  Otherwise, we should exit with that DTMF.
@@ -1132,7 +1139,6 @@ static int pbx_builtin_background(struct ast_channel *chan, const char *data)
         * be returned (see #16434).
         */
        if (!ast_test_flag(ast_channel_flags(chan), AST_FLAG_DISABLE_WORKAROUNDS)
-               && (exten[0] = res)
                && ast_canmatch_extension(chan, args.context, exten, 1,
                        S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL))
                && !ast_matchmore_extension(chan, args.context, exten, 1,