]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
app_read: Fix custom terminator functionality regression
authorNaveen Albert <asterisk@phreaknet.org>
Mon, 25 Oct 2021 17:51:50 +0000 (17:51 +0000)
committerKevin Harwell <kharwell@digium.com>
Tue, 16 Nov 2021 21:44:10 +0000 (15:44 -0600)
Currently, when the t option is specified with no arguments,
the # character is still treated as a terminator, even though
no character should be treated as a terminator.

This is because a previous regression fix was modified to
remove the use of NULL as a default altogether. However,
NULL and an empty string actually refer to different
arrangements and should be treated differently. NULL is the
default terminator (#), while an empty string removes the
terminator altogether. This is the behavior being used by
the rest of the core.

Additionally, since S_OR catches empty strings as well as
NULL (not intended), this is changed to a ternary operator
instead, which fixes the behavior.

ASTERISK-29705 #close

Change-Id: I9b6b72196dd04f5b1e0ab5aa1b0adf627725e086

apps/app_read.c
main/app.c

index 977b20dc2956402900c845b41e06a711b75c10d9..f4a965c8b46d36b64772a2803f4e677467b20d44 100644 (file)
@@ -250,7 +250,7 @@ static int read_exec(struct ast_channel *chan, const char *data)
                                                break;
                                        }
                                        tmp[x++] = res;
-                                       if (strchr(terminator, tmp[x-1])) {
+                                       if (terminator && strchr(terminator, tmp[x-1])) {
                                                tmp[x-1] = '\0';
                                                status = "OK";
                                                break;
index f5fbffd7f7eef7d61950d4ad6d2ccdb92df16d4b..411d5077b05f202b7f74e9d2f0ef39c81897fc11 100644 (file)
@@ -249,7 +249,7 @@ enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const
                        fto = 50;
                        to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
                }
-               res = ast_readstring(c, s, maxlen, to, fto, S_OR(terminator, "#"));
+               res = ast_readstring(c, s, maxlen, to, fto, (terminator ? terminator : "#"));
                if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
                        return res;
                }