chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] update klibc to version 0.181
[elogind.git]
/
klibc
/
klibc
/
strncpy.c
diff --git
a/klibc/klibc/strncpy.c
b/klibc/klibc/strncpy.c
index a8fe45fcbb588bccb28c9fadaf821adef5e0df10..06964f31d687c3ef7acabf3c9ce6076e60de103c 100644
(file)
--- a/
klibc/klibc/strncpy.c
+++ b/
klibc/klibc/strncpy.c
@@
-1,7
+1,5
@@
/*
* strncpy.c
/*
* strncpy.c
- *
- * strncpy()
*/
#include <string.h>
*/
#include <string.h>
@@
-12,11
+10,15
@@
char *strncpy(char *dst, const char *src, size_t n)
const char *p = src;
char ch;
const char *p = src;
char ch;
- while ( n-- ) {
+ while (n) {
+ n--;
*q++ = ch = *p++;
if ( !ch )
break;
}
*q++ = ch = *p++;
if ( !ch )
break;
}
+ /* The specs say strncpy() fills the entire buffer with NUL. Sigh. */
+ memset(q, 0, n);
+
return dst;
}
return dst;
}