[sr-dev] [kamailio/kamailio] janssonrpcc: Fix invalid memory access by zero terminating str, cleanups (#2512)

Daniel-Constantin Mierla notifications at github.com
Tue Oct 20 09:08:54 CEST 2020


I would rather change pkg_str_dup() and shm_str_dup() to allocate len+1 and add the ending zero, right now there are not widely used and at the end is just adding an extra operation `newbuf->s[len] = '\0';`. IMO it will be better and safer in long term, as one can then use standard string operations with newbuf->s. For that reason, over the years the values for variables (like avp, xavp, ...) were made zero-terminated.

STR_VTOZ macro is useful when one knows that the string is stored inside a larger buffer, so temporarily setting an ending 0 doesn't go over allocated memory, otherwise can end up in segmentation fault.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/2512#issuecomment-712643111
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20201020/30658513/attachment.htm>


More information about the sr-dev mailing list