diff options
Diffstat (limited to 'kernel/libc')
-rw-r--r-- | kernel/libc/include/string.h | 1 | ||||
-rw-r--r-- | kernel/libc/string/copy.c | 9 | ||||
-rw-r--r-- | kernel/libc/string/strncpy.c | 11 |
3 files changed, 5 insertions, 16 deletions
diff --git a/kernel/libc/include/string.h b/kernel/libc/include/string.h index 707d391..89ea5ab 100644 --- a/kernel/libc/include/string.h +++ b/kernel/libc/include/string.h @@ -13,7 +13,6 @@ int isequal(const char *s1, const char *s2); int isequal_n(const char *s1, const char *s2, u32 n); char *copy_and_allocate_string(const char *s); char *copy_and_allocate_user_string(const char *s); -char *strncpy(char *dest, const char *src, size_t n); size_t strlcpy(char *dst, const char *src, size_t dsize); char *strcat(char *s1, const char *s2); #endif 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; } diff --git a/kernel/libc/string/strncpy.c b/kernel/libc/string/strncpy.c deleted file mode 100644 index a886895..0000000 --- a/kernel/libc/string/strncpy.c +++ /dev/null @@ -1,11 +0,0 @@ -#include <stddef.h> -#include <string.h> - -// FIXME: Something is weird with this function -char *strncpy(char *dest, const char *src, size_t n) { - char *r = dest; - for (; n && (*dest = *src); n--, src++, dest++) - ; - *dest = '\0'; - return r; -} |