[Home]

Summary:ASTERISK-28454: res_fax.c UTF-8 validation for remotestationid and pbx_builtin_setvar_helper
Reporter:Jodi Jones (jodi@devoli.com)Labels:fax
Date Opened:2019-06-19 16:21:25Date Closed:2019-06-19 17:54:28
Priority:MinorRegression?
Status:Closed/CompleteComponents:Resources/res_fax
Versions:16.4.0 Frequency of
Occurrence
Constant
Related
Issues:
duplicatesASTERISK-27082 res_fax: Error building JSON, Invalid UTF-8 string due to invalid FAX CSI string format
Environment:LinuxAttachments:
Description:A UTF-8 validation needs to be added to https://github.com/asterisk/asterisk/blob/master/res/res_fax.c#L1450, invalid utf-8 causes a segfault via json

IE

{code}
[Jun 10 17:08:15] VERBOSE[12546][C-00000003] res_fax.c: Channel 'SIP/VIBE-XC5-XS1-00000002' receiving FAX '/var/spool/asterisk/fax/fax-xxxxxx.tif'
[Jun 10 17:08:16] VERBOSE[12545][C-00000002] netsock2.c: Using UDPTL CoS mark 5
[Jun 10 17:08:18] VERBOSE[12546][C-00000003] netsock2.c: Using UDPTL CoS mark 5
[Jun 10 17:08:51] ERROR[12545][C-00000002] json.c: Error building JSON from '{s: s, s: s}': Invalid UTF-8 string.
[Jun 10 17:08:51] ERROR[12545][C-00000002] : Got 13 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0x94) [0x4f77f4]
# 1: /usr/sbin/asterisk(ast_channel_publish_varset+0x2b) [0x57dd2b]
# 2: /usr/sbin/asterisk(pbx_builtin_setvar_helper+0x123) [0x533f13]
# 3: /usr/lib/asterisk/modules/res_fax.so(+0x3de2) [0x7fdfe67a2de2]
# 4: /usr/lib/asterisk/modules/res_fax.so(+0x95a7) [0x7fdfe67a85a7]
# 5: /usr/lib/asterisk/modules/res_fax.so(+0x10df5) [0x7fdfe67afdf5]
# 6: /usr/sbin/asterisk(pbx_exec+0xb9) [0x52ad09]
# 7: /usr/sbin/asterisk() [0x51e6d5]
# 8: /usr/sbin/asterisk() [0x520744]
# 9: /usr/sbin/asterisk() [0x521ccb]
#10: /usr/sbin/asterisk() [0x59e179]
#11: /lib64/libpthread.so.0(+0x7dd5) [0x7fe037454dd5]
#12: /lib64/libc.so.6(clone+0x6d) [0x7fe0364f4ead]

[Jun 10 17:08:51] ERROR[12545][C-00000002] stasis_channels.c: Error creating message
[Jun 10 17:08:51] ERROR[12545][C-00000002] json.c: Error building JSON from '{s: s, s: s, s: s, s: s, s: s, s: s, s: o}': Invalid UTF-8 string.
[Jun 10 17:08:51] ERROR[12545][C-00000002] : Got 10 backtrace records
# 0: /usr/sbin/asterisk(ast_json_pack+0x94) [0x4f77f4]
# 1: /usr/lib/asterisk/modules/res_fax.so(+0x50c8) [0x7fdfe67a40c8]
# 2: /usr/lib/asterisk/modules/res_fax.so(+0x10e4a) [0x7fdfe67afe4a]
# 3: /usr/sbin/asterisk(pbx_exec+0xb9) [0x52ad09]
# 4: /usr/sbin/asterisk() [0x51e6d5]
# 5: /usr/sbin/asterisk() [0x520744]
# 6: /usr/sbin/asterisk() [0x521ccb]
# 7: /usr/sbin/asterisk() [0x59e179]
# 8: /lib64/libpthread.so.0(+0x7dd5) [0x7fe037454dd5]
# 9: /lib64/libc.so.6(clone+0x6d) [0x7fe0364f4ead]
{code}

Here is the character in question from the FAXOPT

{code}
[Jun 10 17:08:51] VERBOSE[12545][C-00000002] pbx.c: Executing [h@fax-rx:9] NoOp("SIP/VIBE-XC5-XS1-00000001", "FAXOPT(remotestationid) : ▒▒▒▒ ") in new stack
{code}

Validated segfault goes away by  not referencing *details->remotestationid* and using a static string in the function *set_channel_variables* from *res_fax.c*.

Band-aid solution for our production environment (i understand this is not a proper fix)

{code}
       //pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", S_OR(details->remotestationid, NULL));
       pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", S_OR("utf8_bypass", NULL));
{code}

We were getting several segfaults an hour when receiving fax's with dodgy remote station id's... we haven't had a single segfault since applying this work around.
Comments:By: Asterisk Team (asteriskteam) 2019-06-19 16:21:26.498-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: Joshua C. Colp (jcolp) 2019-06-19 17:01:25.794-0500

Looks like this is already reported at ASTERISK-27082.

By: Jodi Jones (jodi@devoli.com) 2019-06-19 17:03:47.443-0500

reported 2 years ago... still hasn't been resolved :\

By: Asterisk Team (asteriskteam) 2019-06-19 17:03:47.719-0500

This issue has been reopened as a result of your commenting on it as the reporter. It will be triaged once again as applicable.

By: Joshua C. Colp (jcolp) 2019-06-19 17:54:28.488-0500

As Asterisk is an open source project there is no time frame on when things will get looked into. Anyone is able to pick an issue and work on it if they so desire.