[OpenSIPS-Devel] [opensips] Using {s.substr}{s.hex2dec} is bogus (#296)

gergelypeli notifications at github.com
Mon Aug 11 19:45:52 CEST 2014


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

"100"{s.substr,0,2}{s.hex2dec} is 256 instead of 16
"10x"{s.substr,0,2}{s.hex2dec} is null instead of 16

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.

The hex2dec transformation checking for the string length should solve both issues.


---
Reply to this email directly or view it on GitHub:
https://github.com/OpenSIPS/opensips/issues/296
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/devel/attachments/20140811/f39e911b/attachment.htm>


More information about the Devel mailing list