[Asterisk-code-review] res_fax: validate the remote/local Station ID for UTF-8 format (asterisk[16])
Alexei Gradinari
asteriskteam at digium.com
Tue Feb 23 10:35:10 CST 2021
Alexei Gradinari has uploaded this change for review. ( https://gerrit.asterisk.org/c/asterisk/+/15493 )
Change subject: res_fax: validate the remote/local Station ID for UTF-8 format
......................................................................
res_fax: validate the remote/local Station ID for UTF-8 format
If the remote Station ID contains invalid UTF-8 characters
the asterisk fails to publish Stasis and ReceiveFax status messages.
json.c: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
...
stasis_channels.c: Error creating message
json.c: Error building JSON from '{s: s, s: s, s: s, s: s, s: s, s: s, s: o}': Invalid UTF-8 string.
res_fax.c: Error publishing ReceiveFax status message
This patch replaces the invalid UTF-8 Station IDs with an empty string.
Change-Id: Ieb00b6ecf67db3bfca787649caa8517f29d987db
---
M res/res_fax.c
1 file changed, 6 insertions(+), 6 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/93/15493/1
diff --git a/res/res_fax.c b/res/res_fax.c
index 190ba1b..ff974cb 100644
--- a/res/res_fax.c
+++ b/res/res_fax.c
@@ -1451,8 +1451,8 @@
pbx_builtin_setvar_helper(chan, "FAXSTATUS", S_OR(details->result, NULL));
pbx_builtin_setvar_helper(chan, "FAXERROR", S_OR(details->error, NULL));
pbx_builtin_setvar_helper(chan, "FAXSTATUSSTRING", S_OR(details->resultstr, NULL));
- pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", S_OR(details->remotestationid, NULL));
- pbx_builtin_setvar_helper(chan, "LOCALSTATIONID", S_OR(details->localstationid, NULL));
+ pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", AST_JSON_UTF8_VALIDATE(details->remotestationid));
+ pbx_builtin_setvar_helper(chan, "LOCALSTATIONID", AST_JSON_UTF8_VALIDATE(details->localstationid));
pbx_builtin_setvar_helper(chan, "FAXBITRATE", S_OR(details->transfer_rate, NULL));
pbx_builtin_setvar_helper(chan, "FAXRESOLUTION", S_OR(details->resolution, NULL));
@@ -2036,11 +2036,11 @@
const char *fax_bitrate;
SCOPED_CHANNELLOCK(lock, chan);
- remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");
+ remote_station_id = AST_JSON_UTF8_VALIDATE(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"));
if (!ast_strlen_zero(remote_station_id)) {
remote_station_id = ast_strdupa(remote_station_id);
}
- local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");
+ local_station_id = AST_JSON_UTF8_VALIDATE(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"));
if (!ast_strlen_zero(local_station_id)) {
local_station_id = ast_strdupa(local_station_id);
}
@@ -2543,11 +2543,11 @@
const char *fax_bitrate;
SCOPED_CHANNELLOCK(lock, chan);
- remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");
+ remote_station_id = ast_json_utf8_check(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"));
if (!ast_strlen_zero(remote_station_id)) {
remote_station_id = ast_strdupa(remote_station_id);
}
- local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");
+ local_station_id = ast_json_utf8_check(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"));
if (!ast_strlen_zero(local_station_id)) {
local_station_id = ast_strdupa(local_station_id);
}
--
To view, visit https://gerrit.asterisk.org/c/asterisk/+/15493
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: 16
Gerrit-Change-Id: Ieb00b6ecf67db3bfca787649caa8517f29d987db
Gerrit-Change-Number: 15493
Gerrit-PatchSet: 1
Gerrit-Owner: Alexei Gradinari <alex2grad at gmail.com>
Gerrit-MessageType: newchange
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20210223/45c2fde4/attachment.html>
More information about the asterisk-code-review
mailing list