From c781584936361a921a9f1f6b0491341aaae5c2b8 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Fri, 25 Apr 2008 23:07:39 +0000 Subject: libpayload: Add the null terminator to the end of the duplicated string Signed-off-by: Jordan Crouse Acked-by: Myles Watson git-svn-id: svn://svn.coreboot.org/coreboot/trunk@3268 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- payloads/libpayload/libc/string.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'payloads') diff --git a/payloads/libpayload/libc/string.c b/payloads/libpayload/libc/string.c index 1e9b8bc01c..e86f2c924a 100644 --- a/payloads/libpayload/libc/string.c +++ b/payloads/libpayload/libc/string.c @@ -173,11 +173,12 @@ char *strchr(const char *s, int c) char *strdup(const char *s) { int n = strlen(s); - char *p = malloc(n); + char *p = malloc(n + 1); if (p != NULL) strncpy(p, s, n); + p[n] = 0; return p; } -- cgit v1.2.3