diff options
Diffstat (limited to 'kernel/libc/string/copy.c')
-rw-r--r-- | kernel/libc/string/copy.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/kernel/libc/string/copy.c b/kernel/libc/string/copy.c index 11cd664..4acbbf4 100644 --- a/kernel/libc/string/copy.c +++ b/kernel/libc/string/copy.c @@ -4,12 +4,13 @@ #include <string.h> char *copy_and_allocate_string(const char *s) { - size_t l = strlen(s); - char *r = kmalloc(l + 1); + size_t l = strlen(s) + 1; + char *r = kmalloc(l); if (!r) { return NULL; } - return strncpy(r, s, l); + memcpy(r, s, l); + return r; } char *copy_and_allocate_user_string(const char *s) { @@ -24,6 +25,6 @@ char *copy_and_allocate_user_string(const char *s) { if (!r) { return NULL; } - strlcpy(r, s, len); + memcpy(r, s, len+1); return r; } |