From ac29d61a454f0562c5c63ea1f5e14f9068904bf0 Mon Sep 17 00:00:00 2001 From: Stefan Reinauer Date: Mon, 26 Jan 2009 00:57:54 +0000 Subject: fix a potential null pointer reference in strdup (as found by Patrick Georgi) Signed-off-by: Stefan Reinauer Acked-by: Stefan Reinauer git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3902 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- payloads/libpayload/libc/string.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'payloads/libpayload') diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c index 9502acfa6e..b9ecb907f6 100644 --- a/payloads/libpayload/libc/string.c +++ b/payloads/libpayload/libc/string.c @@ -212,10 +212,10 @@ char *strdup(const char *s) int n = strlen(s); char *p = malloc(n + 1); - if (p != NULL) + if (p != NULL) { strncpy(p, s, n); - - p[n] = 0; + p[n] = 0; + } return p; } -- cgit v1.2.3