<p></p>
<p>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 <code>newbuf->s[len] = '\0';</code>. 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.</p>
<p>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.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/kamailio/kamailio/pull/2512#issuecomment-712643111">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABO7UZP6ATN2EQ7FC57OQX3SLUZQNANCNFSM4SWDGBOQ">unsubscribe</a>.<img src="https://github.com/notifications/beacon/ABO7UZJARUVLYBE4XCQT2LDSLUZQNA5CNFSM4SWDGBO2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOFJ5BEJY.gif" height="1" width="1" alt="" /></p>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/kamailio/kamailio/pull/2512#issuecomment-712643111",
"url": "https://github.com/kamailio/kamailio/pull/2512#issuecomment-712643111",
"name": "View Pull Request"
},
"description": "View this Pull Request on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]</script>