BUG FIX: "Buffer size sanity check failed!" drops FAX receiving unneeded
Hello FreeSwitch users and programmers, I found a problem on receiving faxes and want to share a working patch for this. The problem is that on receiving a fax, it is unneeded aborted by a sanity check. Sanity checks are fine, but a unneeded abort instead of a warning is in productive versions not the best solution. The message apearing is: 2011-04-04 10:44:52.060860 [CRIT] switch_core_codec.c:660 Buffer size sanity check failed! which is normaly aborting in receiving the fax. Simply decreasing this fault to a warning let the server receive the fax without any problems. After the patch the message apears up to five times per fax before the fax is beeing accepted. I am using libpri with the three HFC ISDN Cards and the DAHDI from Debian Squeeze 6.0. For more informations about my hardware just write me an email. Regards, Markus Mueller http://projekte.priv.de/ root@sip:/usr/local/src/freeswitch/src# diff -U 4 switch_core_codec.c* --- switch_core_codec.c 2011-03-14 10:49:17.000000000 +0100 +++ switch_core_codec.c.org 2011-03-14 10:47:02.000000000 +0100 @@ -657,9 +657,9 @@ uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet; if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n"); - // return SWITCH_STATUS_GENERR; + return SWITCH_STATUS_GENERR; } } if (codec->mutex) switch_mutex_lock(codec->mutex); root@sip:/usr/local/src/freeswitch/src#
Please report this issue to Jira. http://jira.freeswitch.org Include all relevent information including how to produce, debug logs and any patch you may have with git diff -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/BUG-FIX-Buffer-size-sanity-che... Sent from the freeswitch-users mailing list archive at Nabble.com.
Can you please get a pcap of a single call (without your patch) as well as a full capture of the freeswitch console logs and post it to JIRA. Are you using the described TDM inside FreeSWITCH or is this a SIP call from an Asterisk machine? On Mon, Apr 4, 2011 at 4:07 AM, Markus Mueller <freeswitch@priv.de> wrote:
Hello FreeSwitch users and programmers,
I found a problem on receiving faxes and want to share a working patch for this. The problem is that on receiving a fax, it is unneeded aborted by a sanity check. Sanity checks are fine, but a unneeded abort instead of a warning is in productive versions not the best solution.
The message apearing is:
2011-04-04 10:44:52.060860 [CRIT] switch_core_codec.c:660 Buffer size sanity check failed!
which is normaly aborting in receiving the fax. Simply decreasing this fault to a warning let the server receive the fax without any problems. After the patch the message apears up to five times per fax before the fax is beeing accepted. I am using libpri with the three HFC ISDN Cards and the DAHDI from Debian Squeeze 6.0. For more informations about my hardware just write me an email.
Regards, Markus Mueller http://projekte.priv.de/
root@sip:/usr/local/src/freeswitch/src# diff -U 4 switch_core_codec.c* --- switch_core_codec.c 2011-03-14 10:49:17.000000000 +0100 +++ switch_core_codec.c.org 2011-03-14 10:47:02.000000000 +0100 @@ -657,9 +657,9 @@ uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet;
if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n"); - // return SWITCH_STATUS_GENERR; + return SWITCH_STATUS_GENERR; } }
if (codec->mutex) switch_mutex_lock(codec->mutex); root@sip:/usr/local/src/freeswitch/src#
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
I can second this behaviour... It wont be the weekend until I can actually get any packet captures for the unpatched code, I can certianly find some full freeswitch console logs if that will help. Has a JIRA bug been filed for this yet? What is the number so I can contribute? Matt. On 7 April 2011 02:05, Anthony Minessale <anthony.minessale@gmail.com>wrote:
Can you please get a pcap of a single call (without your patch) as well as a full capture of the freeswitch console logs and post it to JIRA.
Are you using the described TDM inside FreeSWITCH or is this a SIP call from an Asterisk machine?
On Mon, Apr 4, 2011 at 4:07 AM, Markus Mueller <freeswitch@priv.de> wrote:
Hello FreeSwitch users and programmers,
I found a problem on receiving faxes and want to share a working patch for this. The problem is that on receiving a fax, it is unneeded aborted by a sanity check. Sanity checks are fine, but a unneeded abort instead of a warning is in productive versions not the best solution.
The message apearing is:
2011-04-04 10:44:52.060860 [CRIT] switch_core_codec.c:660 Buffer size sanity check failed!
which is normaly aborting in receiving the fax. Simply decreasing this fault to a warning let the server receive the fax without any problems. After the patch the message apears up to five times per fax before the fax is beeing accepted. I am using libpri with the three HFC ISDN Cards and the DAHDI from Debian Squeeze 6.0. For more informations about my hardware just write me an email.
Regards, Markus Mueller http://projekte.priv.de/
root@sip:/usr/local/src/freeswitch/src# diff -U 4 switch_core_codec.c* --- switch_core_codec.c 2011-03-14 10:49:17.000000000 +0100 +++ switch_core_codec.c.org 2011-03-14 10:47:02.000000000 +0100 @@ -657,9 +657,9 @@ uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet;
if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n"); - // return SWITCH_STATUS_GENERR; + return SWITCH_STATUS_GENERR; } }
if (codec->mutex) switch_mutex_lock(codec->mutex); root@sip:/usr/local/src/freeswitch/src#
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
I think I have a fix for it. The patch provided would lead to memory corruption by feeding data to the codec decoder that probably is not even really audio data with a length that would cause a buffer overflow. Instead when this happens I think I can write out all zeros to the buffer at the typical packet len and return that. Since these frames really should be ignored anyway. I would like to see the pcaps nevertheless so I can identify why it happens. On Wed, Apr 6, 2011 at 5:15 PM, Matt Paine <mattzerah+freeswitch@gmail.com> wrote:
I can second this behaviour... It wont be the weekend until I can actually get any packet captures for the unpatched code, I can certianly find some full freeswitch console logs if that will help. Has a JIRA bug been filed for this yet? What is the number so I can contribute? Matt.
On 7 April 2011 02:05, Anthony Minessale <anthony.minessale@gmail.com> wrote:
Can you please get a pcap of a single call (without your patch) as well as a full capture of the freeswitch console logs and post it to JIRA.
Are you using the described TDM inside FreeSWITCH or is this a SIP call from an Asterisk machine?
On Mon, Apr 4, 2011 at 4:07 AM, Markus Mueller <freeswitch@priv.de> wrote:
Hello FreeSwitch users and programmers,
I found a problem on receiving faxes and want to share a working patch for this. The problem is that on receiving a fax, it is unneeded aborted by a sanity check. Sanity checks are fine, but a unneeded abort instead of a warning is in productive versions not the best solution.
The message apearing is:
2011-04-04 10:44:52.060860 [CRIT] switch_core_codec.c:660 Buffer size sanity check failed!
which is normaly aborting in receiving the fax. Simply decreasing this fault to a warning let the server receive the fax without any problems. After the patch the message apears up to five times per fax before the fax is beeing accepted. I am using libpri with the three HFC ISDN Cards and the DAHDI from Debian Squeeze 6.0. For more informations about my hardware just write me an email.
Regards, Markus Mueller http://projekte.priv.de/
root@sip:/usr/local/src/freeswitch/src# diff -U 4 switch_core_codec.c* --- switch_core_codec.c 2011-03-14 10:49:17.000000000 +0100 +++ switch_core_codec.c.org 2011-03-14 10:47:02.000000000 +0100 @@ -657,9 +657,9 @@ uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet;
if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n"); - // return SWITCH_STATUS_GENERR; + return SWITCH_STATUS_GENERR; } }
if (codec->mutex) switch_mutex_lock(codec->mutex); root@sip:/usr/local/src/freeswitch/src#
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
To all involved: I had to manually remember this issue in my head (13 days old) you provided no traces, I just added a workaround and committed it. I very politely asked you to open a JIRA and offered free help. If you ever do this again I will remove you from the list...... On Wed, Apr 6, 2011 at 8:30 PM, Anthony Minessale <anthony.minessale@gmail.com> wrote:
I think I have a fix for it. The patch provided would lead to memory corruption by feeding data to the codec decoder that probably is not even really audio data with a length that would cause a buffer overflow.
Instead when this happens I think I can write out all zeros to the buffer at the typical packet len and return that. Since these frames really should be ignored anyway.
I would like to see the pcaps nevertheless so I can identify why it happens.
On Wed, Apr 6, 2011 at 5:15 PM, Matt Paine <mattzerah+freeswitch@gmail.com> wrote:
I can second this behaviour... It wont be the weekend until I can actually get any packet captures for the unpatched code, I can certianly find some full freeswitch console logs if that will help. Has a JIRA bug been filed for this yet? What is the number so I can contribute? Matt.
On 7 April 2011 02:05, Anthony Minessale <anthony.minessale@gmail.com> wrote:
Can you please get a pcap of a single call (without your patch) as well as a full capture of the freeswitch console logs and post it to JIRA.
Are you using the described TDM inside FreeSWITCH or is this a SIP call from an Asterisk machine?
On Mon, Apr 4, 2011 at 4:07 AM, Markus Mueller <freeswitch@priv.de> wrote:
Hello FreeSwitch users and programmers,
I found a problem on receiving faxes and want to share a working patch for this. The problem is that on receiving a fax, it is unneeded aborted by a sanity check. Sanity checks are fine, but a unneeded abort instead of a warning is in productive versions not the best solution.
The message apearing is:
2011-04-04 10:44:52.060860 [CRIT] switch_core_codec.c:660 Buffer size sanity check failed!
which is normaly aborting in receiving the fax. Simply decreasing this fault to a warning let the server receive the fax without any problems. After the patch the message apears up to five times per fax before the fax is beeing accepted. I am using libpri with the three HFC ISDN Cards and the DAHDI from Debian Squeeze 6.0. For more informations about my hardware just write me an email.
Regards, Markus Mueller http://projekte.priv.de/
root@sip:/usr/local/src/freeswitch/src# diff -U 4 switch_core_codec.c* --- switch_core_codec.c 2011-03-14 10:49:17.000000000 +0100 +++ switch_core_codec.c.org 2011-03-14 10:47:02.000000000 +0100 @@ -657,9 +657,9 @@ uint32_t frames = encoded_data_len / codec->implementation->encoded_bytes_per_packet;
if (frames && codec->implementation->decoded_bytes_per_packet * frames > *decoded_data_len) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Buffer size sanity check failed!\n"); - // return SWITCH_STATUS_GENERR; + return SWITCH_STATUS_GENERR; } }
if (codec->mutex) switch_mutex_lock(codec->mutex); root@sip:/usr/local/src/freeswitch/src#
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_______________________________________________ FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
participants (4)
-
Anthony Minessale
-
Jeff Lenk
-
Markus Mueller
-
Matt Paine