Skip to content

Commit 2320a96

Browse files
InterLinked1kharwell
authored andcommitted
app_read: Fix custom terminator functionality regression
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
1 parent 126de28 commit 2320a96

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

apps/app_read.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ static int read_exec(struct ast_channel *chan, const char *data)
250250
break;
251251
}
252252
tmp[x++] = res;
253-
if (strchr(terminator, tmp[x-1])) {
253+
if (terminator && strchr(terminator, tmp[x-1])) {
254254
tmp[x-1] = '\0';
255255
status = "OK";
256256
break;

main/app.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ enum ast_getdata_result ast_app_getdata_terminator(struct ast_channel *c, const
249249
fto = 50;
250250
to = ast_channel_pbx(c) ? ast_channel_pbx(c)->dtimeoutms : 2000;
251251
}
252-
res = ast_readstring(c, s, maxlen, to, fto, S_OR(terminator, "#"));
252+
res = ast_readstring(c, s, maxlen, to, fto, (terminator ? terminator : "#"));
253253
if (res == AST_GETDATA_EMPTY_END_TERMINATED) {
254254
return res;
255255
}

0 commit comments

Comments
 (0)