summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--payloads/libpayload/libc/string.c3
1 files changed, 2 insertions, 1 deletions
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;
}