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@amd.com Acked-by: Myles Watson mylesgw@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; }