[sr-dev] [kamailio/kamailio] mtree: fix handling of character values >= 0x80 (#1343)

Timo Teräs notifications at github.com
Wed Nov 29 09:54:05 CET 2017


#### Type Of Change
- [X] Small bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds new functionality)
- [ ] Breaking change (fix or feature that would change existing functionality)

#### Checklist:
- [X ] PR should be backported to stable branches
- [ ] Tested changes locally
- [ ] Related to issue #XXXX (replace XXXX with an open issue number)

#### Description

This fixes mtree to be able to contain strings with character
values larger than 0x80. Previously this would not work because
the str.s[i] is 'char' and when cast to 'unsigned int' it would
be first sign extended for maximum range (on systems where 'char'
defaults to signed). E.g. on x86_64 system:
 (unsigned int)(char)0x80 = 4294967168

The >=MT_CHAR_TABLE_SIZE test would filter any string containing
these characters out as invalid.

Code is fixed to cast _mt_char_table index to 'unsigned char'
always so index is within range always. The new redundant checks
against MT_CHAR_TABLE_SIZE are removed, and the result is stored
to local variable (and used from it) to improve code readability.

The error message in mt_add_to_tree() is harmonized with the other
messages to show the full string with a problem.

You can view, comment on, or merge this pull request online at:

  https://github.com/kamailio/kamailio/pull/1343

-- Commit Summary --

  * mtree: fix handling of character values >= 0x80

-- File Changes --

    M src/modules/mtree/mtree.c (132)

-- Patch Links --

https://github.com/kamailio/kamailio/pull/1343.patch
https://github.com/kamailio/kamailio/pull/1343.diff

-- 
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/pull/1343
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-dev/attachments/20171129/2b234dc3/attachment.html>


More information about the sr-dev mailing list