fix strncpy buffer overrun

This commit is contained in:
Tomoki Shirasawa
2014-10-01 09:04:11 +09:00
parent 8751b32b30
commit f3ea226d91

View File

@@ -50,9 +50,11 @@ char *strncpy(char *dest, const char *src, size_t maxlen)
char *head = dest;
ssize_t len = maxlen;
if(len <= 0)
return head;
while((*(dest++) = *(src++)) && --len);
if(len > 0){
while(len--){
while(--len){
*(dest++) = '\0';
}
}