summaryrefslogtreecommitdiffstatshomepage
path: root/lib/libc/string0.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libc/string0.c')
-rw-r--r--lib/libc/string0.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/libc/string0.c b/lib/libc/string0.c
index 1b37169edd..be003a1bc1 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) {