From bd9de5ec9020384334b63582c7640372a9a2d022 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Mon, 2 May 2016 18:38:19 +0300
Subject: [PATCH] lib/libc/string0: Add strncpy() implementation.

---
 lib/libc/string0.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/lib/libc/string0.c b/lib/libc/string0.c
index 1b37169ed..be003a1bc 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) {
-- 
GitLab