LibC: Fix strncat
strncat was using strncpy internally which nullpadded dest until n bytes were written. also there was no terminating null byte added if src was shorter than n bytes
This commit is contained in:
parent
bdbde25784
commit
88abbd90dc
|
@ -147,7 +147,10 @@ char* strcat(char* __restrict__ dest, const char* __restrict__ src)
|
|||
|
||||
char* strncat(char* __restrict__ dest, const char* __restrict__ src, size_t n)
|
||||
{
|
||||
strncpy(dest + strlen(dest), src, n);
|
||||
dest += strlen(dest);
|
||||
while (*src && n--)
|
||||
*dest++ = *src++;
|
||||
*dest = '\0';
|
||||
return dest;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue