Completes unfinished business from commit d8d0c5f which added the aux->finished flag, but failed to update the line that checks for the finished condition before processing sep.
Also fixes some bugs:
Calling kstrtok(str, "", aux); would cause an illegal access to the byte after the sep string (and possibly beyond if that byte was not 0).
On platforms where char is signed (usually the case on x86), calling kstrtok(str, "\xff", aux) would cause aux->sep to be set to -1 and not 255 as intended. This results in the bitmap-based path being incorrectly used when scanning the string.
Completes unfinished business from commit d8d0c5f which added the aux->finished flag, but failed to update the line that checks for the finished condition before processing
sep
.Also fixes some bugs:
kstrtok(str, "", aux);
would cause an illegal access to the byte after thesep
string (and possibly beyond if that byte was not 0).char
is signed (usually the case on x86), callingkstrtok(str, "\xff", aux)
would cause aux->sep to be set to -1 and not 255 as intended. This results in the bitmap-based path being incorrectly used when scanning the string.aux->p = str - 1
could result in undefined behaviour asstr - 1
may be outside the array object which contains the string. This is not allowed by the C standard (see, for example, https://wiki.sei.cmu.edu/confluence/display/c/ARR30-C.+Do+not+form+or+use+out-of-bounds+pointers+or+array+subscripts), even if the pointer is never actually dereferenced.