[Freeswitch-dev] Substutions in XML dial plan
Hello, My dial plan contains something like the following: <action application="bridge" data="sofia/profile1/$1,sofia/profile2/$1"/> This causes a problem in mod_dialplan_xml.c, near line 150: len = (uint32_t) (strlen(data) + strlen(field_data) + 10); if (!(substituted = malloc(len))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n"); proceed = 0; goto done; } memset(substituted, 0, len); switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector); app_data = substituted; The problem is simple: len is too small because the $1 pattern appears twice. Therefore adding strlen(field_data) once is not enough. It should be multiplied by the number of times the pattern appears in the string. It seems like someone experienced the same problem before: that would explain the "+ 10" magic number which I am very tempted to just increase to 100. ;-) Is this really a bug or is it my imagination? If it is a bug, how should we go about fixing it? Thanks, Simon -- Please try Numb, a STUN/TURN server implementation. Free access at http://numb.viagenie.ca/.
see if latest trunk fixes it. On Wed, Jun 25, 2008 at 1:16 PM, Simon Perreault < simon.perreault@viagenie.ca> wrote:
Hello,
My dial plan contains something like the following:
<action application="bridge" data="sofia/profile1/$1,sofia/profile2/$1"/>
This causes a problem in mod_dialplan_xml.c, near line 150:
len = (uint32_t) (strlen(data) + strlen(field_data) + 10); if (!(substituted = malloc(len))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "memory error!\n"); proceed = 0; goto done; } memset(substituted, 0, len); switch_perform_substitution(re, proceed, data, field_data, substituted, len, ovector); app_data = substituted;
The problem is simple: len is too small because the $1 pattern appears twice. Therefore adding strlen(field_data) once is not enough. It should be multiplied by the number of times the pattern appears in the string.
It seems like someone experienced the same problem before: that would explain the "+ 10" magic number which I am very tempted to just increase to 100. ;-)
Is this really a bug or is it my imagination? If it is a bug, how should we go about fixing it?
Thanks, Simon
-- Please try Numb, a STUN/TURN server implementation. Free access at http://numb.viagenie.ca/.
_______________________________________________ Freeswitch-dev mailing list Freeswitch-dev@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev http://www.freeswitch.org
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ AIM: anthm MSN:anthony_minessale@hotmail.com <MSN%3Aanthony_minessale@hotmail.com> GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com<PAYPAL%3Aanthony.minessale@gmail.com> IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org <sip%3A888@conference.freeswitch.org> iax:guest@conference.freeswitch.org/888 googletalk:conf+888@conference.freeswitch.org<googletalk%3Aconf%2B888@conference.freeswitch.org> pstn:213-799-1400
participants (2)
-
Anthony Minessale
-
Simon Perreault