<p>When these two transformations are used in this order, the result can be wrong in multiple ways. Pseudocode:</p>

<p>"100"{s.substr,0,2}{s.hex2dec} is 256 instead of 16<br>
"10x"{s.substr,0,2}{s.hex2dec} is null instead of 16</p>

<p>The reason seems to be that the substr transformation just indexes into the original string, while the hex2dec does not check for the string length, so any character that is already chopped off the variable still affects the conversion. If the trailing characters are valid hex digits, they're incorrectly included in the conversion, if not, the conversion incorrectly fails.</p>

<p>The hex2dec transformation checking for the string length should solve both issues.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">&mdash;<br>Reply to this email directly or <a href="https://github.com/OpenSIPS/opensips/issues/296">view it on GitHub</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/5479561__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyMzM5ODM1MiwiZGF0YSI6eyJpZCI6MzkzNjg4NjN9fQ==--4b1fc67cf1fb647ee8a3e6fc97ae485081b21360.gif" width="1" /></p>