[coreboot] r3268 - trunk/payloads/libpayload/libc

svn at coreboot.org svn at coreboot.org
Sat Apr 26 01:07:40 CEST 2008


Author: jcrouse
Date: 2008-04-26 01:07:39 +0200 (Sat, 26 Apr 2008)
New Revision: 3268

Modified:
   trunk/payloads/libpayload/libc/string.c
Log:
libpayload:  Add the null terminator to the end of the duplicated string

Signed-off-by: Jordan Crouse <jordan.crouse at amd.com>
Acked-by: Myles Watson <mylesgw at gmail.com>


Modified: trunk/payloads/libpayload/libc/string.c
===================================================================
--- trunk/payloads/libpayload/libc/string.c	2008-04-25 22:56:57 UTC (rev 3267)
+++ trunk/payloads/libpayload/libc/string.c	2008-04-25 23:07:39 UTC (rev 3268)
@@ -173,11 +173,12 @@
 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;
 }
 





More information about the coreboot mailing list