<p>Alexei Gradinari has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/c/asterisk/+/15493">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_fax: validate the remote/local Station ID for UTF-8 format<br><br>If the remote Station ID contains invalid UTF-8 characters<br>the asterisk fails to publish Stasis and ReceiveFax status messages.<br><br>json.c: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.<br>...<br>stasis_channels.c: Error creating message<br><br>json.c: Error building JSON from '{s: s, s: s, s: s, s: s, s: s, s: s, s: o}': Invalid UTF-8 string.<br>res_fax.c: Error publishing ReceiveFax status message<br><br>This patch replaces the invalid UTF-8 Station IDs with an empty string.<br><br>Change-Id: Ieb00b6ecf67db3bfca787649caa8517f29d987db<br>---<br>M res/res_fax.c<br>1 file changed, 6 insertions(+), 6 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/93/15493/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_fax.c b/res/res_fax.c</span><br><span>index 190ba1b..ff974cb 100644</span><br><span>--- a/res/res_fax.c</span><br><span>+++ b/res/res_fax.c</span><br><span>@@ -1451,8 +1451,8 @@</span><br><span> pbx_builtin_setvar_helper(chan, "FAXSTATUS", S_OR(details->result, NULL));</span><br><span> pbx_builtin_setvar_helper(chan, "FAXERROR", S_OR(details->error, NULL));</span><br><span> pbx_builtin_setvar_helper(chan, "FAXSTATUSSTRING", S_OR(details->resultstr, NULL));</span><br><span style="color: hsl(0, 100%, 40%);">- pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", S_OR(details->remotestationid, NULL));</span><br><span style="color: hsl(0, 100%, 40%);">- pbx_builtin_setvar_helper(chan, "LOCALSTATIONID", S_OR(details->localstationid, NULL));</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", AST_JSON_UTF8_VALIDATE(details->remotestationid));</span><br><span style="color: hsl(120, 100%, 40%);">+ pbx_builtin_setvar_helper(chan, "LOCALSTATIONID", AST_JSON_UTF8_VALIDATE(details->localstationid));</span><br><span> pbx_builtin_setvar_helper(chan, "FAXBITRATE", S_OR(details->transfer_rate, NULL));</span><br><span> pbx_builtin_setvar_helper(chan, "FAXRESOLUTION", S_OR(details->resolution, NULL));</span><br><span> </span><br><span>@@ -2036,11 +2036,11 @@</span><br><span> const char *fax_bitrate;</span><br><span> SCOPED_CHANNELLOCK(lock, chan);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_station_id = AST_JSON_UTF8_VALIDATE(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"));</span><br><span> if (!ast_strlen_zero(remote_station_id)) {</span><br><span> remote_station_id = ast_strdupa(remote_station_id);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ local_station_id = AST_JSON_UTF8_VALIDATE(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"));</span><br><span> if (!ast_strlen_zero(local_station_id)) {</span><br><span> local_station_id = ast_strdupa(local_station_id);</span><br><span> }</span><br><span>@@ -2543,11 +2543,11 @@</span><br><span> const char *fax_bitrate;</span><br><span> SCOPED_CHANNELLOCK(lock, chan);</span><br><span> </span><br><span style="color: hsl(0, 100%, 40%);">- remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ remote_station_id = ast_json_utf8_check(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"));</span><br><span> if (!ast_strlen_zero(remote_station_id)) {</span><br><span> remote_station_id = ast_strdupa(remote_station_id);</span><br><span> }</span><br><span style="color: hsl(0, 100%, 40%);">- local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");</span><br><span style="color: hsl(120, 100%, 40%);">+ local_station_id = ast_json_utf8_check(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"));</span><br><span> if (!ast_strlen_zero(local_station_id)) {</span><br><span> local_station_id = ast_strdupa(local_station_id);</span><br><span> }</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/c/asterisk/+/15493">change 15493</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/c/asterisk/+/15493"/><meta itemprop="name" content="View Change"/></div></div>
<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 16 </div>
<div style="display:none"> Gerrit-Change-Id: Ieb00b6ecf67db3bfca787649caa8517f29d987db </div>
<div style="display:none"> Gerrit-Change-Number: 15493 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Alexei Gradinari <alex2grad@gmail.com> </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>