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

@ -411,7 +411,7 @@ _nb_dns_mkquery(register struct nb_dns_info *nd, register const char *name,
return (-1);
}
memset(ne, 0, sizeof(*ne));
strncpy(ne->name, name, sizeof(ne->name));
strncpy(ne->name, name, sizeof(ne->name) - 1);
ne->name[sizeof(ne->name) - 1] = '\0';
ne->qtype = qtype;
ne->atype = atype;