diff --git a/lib/libc/string0.c b/lib/libc/string0.c
index 1b37169edde886e6e5622ed7f88ef5264f111e08..be003a1bc1d9de5267c3b5a25c503bd24cb0c682 100644
--- a/lib/libc/string0.c
+++ b/lib/libc/string0.c
@@ -169,6 +169,15 @@ char *strcpy(char *dest, const char *src) {
     return dest;
 }
 
+char *strncpy(char *dest, const char *src, size_t dest_sz) {
+    char *d = dest;
+    while (*src && --dest_sz) {
+        *d++ = *src++;
+    }
+    *d = '\0';
+    return dest;
+}
+
 // needed because gcc optimises strcpy + strcat to this
 char *stpcpy(char *dest, const char *src) {
     while (*src) {