XUtils: add safe strncpy implementation

The standard strncpy fails to null-terminate the destination in case
the source is longer than the passed size.
This commit is contained in:
Christian Göttsche
2021-01-05 14:44:09 +01:00
committed by BenBE
parent 3715301fe3
commit a118928dee
2 changed files with 15 additions and 0 deletions

View File

@ -59,6 +59,9 @@ char* String_getToken(const char* line, unsigned short int numMatch);
char* String_readLine(FILE* fd);
/* Always null-terminates dest. Caller must pass a strictly positive size. */
size_t String_safeStrncpy(char *restrict dest, const char *restrict src, size_t size);
ATTR_FORMAT(printf, 2, 3)
int xAsprintf(char** strp, const char* fmt, ...);