summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHarshit Sharma <harshitsharmajs@gmail.com>2020-05-26 00:29:53 +0530
committerPatrick Georgi <pgeorgi@google.com>2020-05-28 09:34:37 +0000
commit0d512179c5e33de51620973250c9e3acf18ad082 (patch)
treee78daf59ca8379f8734fa42912f1f3fd96944578
parent8f2737476805ee9629af1ad16646e6258825a24b (diff)
downloadcoreboot-0d512179c5e33de51620973250c9e3acf18ad082.tar.xz
payloads/libpayload/libc: Avoid NULL pointer dereference
Avoid dereferencing a NULL pointer in case of function parameter 'ptr'. Signed-off-by: Harshit Sharma <harshitsharmajs@gmail.com> Change-Id: I5dba27d9757fb55476f3d5848f0ed26ae9494bee Reviewed-on: https://review.coreboot.org/c/coreboot/+/41698 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--payloads/libpayload/libc/string.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c
index c05a012f51..a481fef7eb 100644
--- a/payloads/libpayload/libc/string.c
+++ b/payloads/libpayload/libc/string.c
@@ -599,8 +599,6 @@ char *strtok_r(char *str, const char *delim, char **ptr)
return start;
}
-static char **strtok_global;
-
/**
* Extract first token in string str that is delimited by a character in tokens.
* Destroys str, eliminates the token delimiter and uses global state.
@@ -610,7 +608,9 @@ static char **strtok_global;
*/
char *strtok(char *str, const char *delim)
{
- return strtok_r(str, delim, strtok_global);
+ static char *strtok_ptr;
+
+ return strtok_r(str, delim, &strtok_ptr);
}
/**