util, nb_dns: fix off-by-one bugs in strncpy() calls

Fortunately, these bugs had no effect because the following lines
overwrote the last character with a null byte.
This commit is contained in:
Max Kellermann 2020-01-22 13:50:17 +01:00
parent aacf84e552
commit 32bb019e3a
3 changed files with 3 additions and 3 deletions

View file

@ -512,7 +512,7 @@ inline void* safe_malloc(size_t size)
inline char* safe_strncpy(char* dest, const char* src, size_t n)
{
char* result = strncpy(dest, src, n);
char* result = strncpy(dest, src, n-1);
dest[n-1] = '\0';
return result;
}