Update safe_strncpy.c

If there is no null byte among the first 'size' bytes of src, 
the dst string will 'still not' be null-terminated.
pull/1/head
Mr.Wang 2016-03-06 12:25:27 +08:00
parent 86d9f60f3a
commit 56c36f1aa1
1 changed files with 1 additions and 1 deletions

View File

@ -14,7 +14,7 @@ char* FAST_FUNC safe_strncpy(char *dst, const char *src, size_t size)
{
if (!size) return dst;
dst[--size] = '\0';
return strncpy(dst, src, size);
return strncpy(dst, src, --size);
}
/* Like strcpy but can copy overlapping strings. */