fix a potential null pointer reference in strdup (as found by Patrick Georgi)
authorStefan Reinauer <stepan@coresystems.de>
Mon, 26 Jan 2009 00:57:54 +0000 (00:57 +0000)
committerStefan Reinauer <stepan@openbios.org>
Mon, 26 Jan 2009 00:57:54 +0000 (00:57 +0000)
Signed-off-by: Stefan Reinauer <stepan@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>
git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3902 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1

payloads/libpayload/libc/string.c

index 9502acfa6ed6546e9a88684f71d8d42c64b691c4..b9ecb907f61e9d6283e754937b1723494f564870 100644 (file)
@@ -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;
 }