Considering the following _fallback case_ :
- alloc dst->s = pointer sizeof(void\*)
- dst->len = 0
- return **0**
After skimming the code a little more I came to this for the above case(i.e.
src->s is NULL):
- either make dst->s = NULL; dst->len = 0 and return **-1**; this will be
caught by shm_str_dup() != 0 and prevent shm_free() a NULL pointer, even though
memory managers checks for this and gives L_WARN
- or keep the fallback case; further uses of the dst should be done based on
the dst->len (i.e. cmp_str() or LM_ERR("%.*s"))
I'd go for the second option. What do you think?
Also I've seen that the memory manager allocate and 'unsigned int'. So, if
shm/pkg_str_dup() is called with src->len < 0 it will probably fail (depending
on the negative value). In this case, I'd also force the fallback case.
---
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/pull/401#issuecomment-157984715_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev