Jérémy Compostella (jeremy.compostella@gmail.com) just uploaded a new patch set to gerrit, which you can find at https://review.coreboot.org/16524
-gerrit
commit beda6de82b8003c34d5853eaa438f695ad230879 Author: Jeremy Compostella jeremy.compostella@intel.com Date: Wed Sep 7 14:09:34 2016 +0200
libpayload: Fix strtok_r
This patch makes strtok_r: - handle the end of the string - handle string that contains only delimiters - do not set ptr outside of str
Change-Id: I49925040d951dffb9c11425334674d8d498821f1 Signed-off-by: Jeremy Compostella jeremy.compostella@gmail.com --- payloads/libpayload/libc/string.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c index 9985749..a58efde 100644 --- a/payloads/libpayload/libc/string.c +++ b/payloads/libpayload/libc/string.c @@ -609,11 +609,15 @@ char* strtok_r(char *str, const char *delim, char **ptr) /* skip over prefix delimiters */ char *start = str + strspn(str, delim);
+ if (start[0] == '\0') + return NULL; + /* find first delimiter character */ char *end = start + strcspn(start, delim); - end[0] = '\0'; + *ptr = end; + if (end[0] != '\0') + *(*ptr)++ = '\0';
- *ptr = end+1; return start; }