]> git.kaiwu.me - klib.git/commit
Fix undefined behaviour and sign extension issues in kstrtok
authorRob Davies <rmd+git@sanger.ac.uk>
Wed, 10 Jan 2018 17:05:57 +0000 (17:05 +0000)
committerRob Davies <rmd+git@sanger.ac.uk>
Thu, 11 Jan 2018 14:30:02 +0000 (14:30 +0000)
commit6b83413b34784eb3956c026c3b955e532f7f02bc
tree07504e0f6267ed69836039f459b1c495924b9c0f
parentefd09f0a00e35f85b4065e30c210110fdfb0f225
Fix undefined behaviour and sign extension issues in kstrtok

Prevent read beyond the end of sep if it's an empty string.

Change to internally use unsigned char to avoid unwanted sign
extension on platforms where 'char' is signed.

Fix undefined behaviour where pointers were made to the element
before the start of `str`:
https://www.securecoding.cert.org/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts
kstring.c