Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-05-02 Thread Daniel-Constantin Mierla
Hello, On 5/2/13 7:55 PM, Martin Mikkelsen wrote: On Wed, May 01, 2013 at 11:04:28AM +0200, Alex Hermann wrote: strncpy() must be replaced with memmove() when src and dst (may) overlap. You are right, it is probably better to do the copying with memove(), then we dont have to fixup all the tra

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-05-02 Thread Martin Mikkelsen
On Wed, May 01, 2013 at 11:04:28AM +0200, Alex Hermann wrote: > strncpy() must be replaced with memmove() when src and dst (may) overlap. You are right, it is probably better to do the copying with memove(), then we dont have to fixup all the transformation functions. -- Martin Mikkelsen (mam...

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-05-01 Thread Alex Hermann
On Tuesday 30 April 2013, Martin Mikkelsen wrote: > This smells memory corruption. When run under valgrind, valgrind > generates this error when that code is run: > > ==1206== Source and destination overlap in strncpy(0x55e3b2a, 0x55e3b2b, > 10) ==1206==at 0x4C25ACF: strncpy (mc_replace_strmem

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Daniel-Constantin Mierla
Hello, On 4/30/13 5:31 PM, Martin Mikkelsen wrote: On Tue, Apr 30, 2013 at 02:42:22PM +0200, Andreas Granig wrote: Hi, We've seen this behaviour as well and worked around it using avp_subst with regex, as we didn't have the time yet to investigate further. I was also able to work around it wi

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
On Tue, Apr 30, 2013 at 02:42:22PM +0200, Andreas Granig wrote: > Hi, > > We've seen this behaviour as well and worked around it using > avp_subst with regex, as we didn't have the time yet to investigate > further. I was also able to work around it with: $var(tmp) = $(var(x){s.substr,1,0});

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Andreas Granig
Hi, We've seen this behaviour as well and worked around it using avp_subst with regex, as we didn't have the time yet to investigate further. But basically I can confirm this issue. Andreas On 04/30/2013 01:31 PM, Martin Mikkelsen wrote: On Tue, Apr 30, 2013 at 01:29:21PM +0200, Martin Mikk

Re: [SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
On Tue, Apr 30, 2013 at 01:29:21PM +0200, Martin Mikkelsen wrote: > I am not sure what the best fix would be for that, but I have attached a > patch which copies the string in the TR_S_SUBST code to _tr_buffer and > returns that buffer instead like a lot of the other transformations in > that funct

[SR-Users] [PATCH] Memory corruption using s.substr transformation

2013-04-30 Thread Martin Mikkelsen
Hello, I have a kamailio 3.3.4 server running on x86-64 Linux, and I have a script which looks something like this: $var(gwruri) = $rU; if ($(var(gwruri){s.substr,0,1}) == "+") { $var(gwruri) = $(var(gwruri){s.substr,1,0}); } When this script is run with say $rU = "+009724" (real n