[sr-dev] [kamailio/kamailio] {s.encode.hexa} transformation does not work as expected (#2690)

iamonte notifications at github.com
Thu Mar 25 14:25:38 CET 2021


We have found an issue in version 5.2
To reproduce it

```
$var(x) = "wg48D8NPIJ5JEfkgqhuu+Q==";
$var(decode64) = $(var(x){s.decode.base64});
$var(encode16) = $(var(decode64){s.encode.hexa});
```

after these line the value of encode16 must be 'c20e3c0fc34f209e4911f920aa1baef9'

Looking inside the module pv, file pv_trans.c, line 347, we realized that the code is not correct because the shift operation keeps the sign,

`_tr_buffer[j++] = fourbits2char[val->rs.s[i] >> 4];`

we saw that if we modifies the previous line with the following

`_tr_buffer[j++] = fourbits2char[(unsigned char)(val->rs.s[i]) >> 4];`

the function works as expected


-- 
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/issues/2690
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20210325/1cd01c4b/attachment.htm>


More information about the sr-dev mailing list