mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-05-21 09:57:24 +00:00
tests: fix strncpy warning
GCC/clang warns about using strncpy in such a way that it does not copy the null byte of a string; as implemented it was fine, but to fix the warning, just use strlcat which was purpose made for the task being accomplished here. Signed-off-by: Quentin Young <qlyoung@qlyoung.net>
This commit is contained in:
parent
90f1e4e017
commit
64c549e68c
@ -19,9 +19,10 @@ static int verbose;
|
||||
static void str_append(char **buf, const char *repr)
|
||||
{
|
||||
if (*buf) {
|
||||
*buf = realloc(*buf, strlen(*buf) + strlen(repr) + 1);
|
||||
size_t new_size = strlen(*buf) + strlen(repr) + 1;
|
||||
*buf = realloc(*buf, new_size);
|
||||
assert(*buf);
|
||||
strncpy((*buf) + strlen(*buf), repr, strlen(repr) + 1);
|
||||
(void)strlcat(*buf, repr, new_size);
|
||||
} else {
|
||||
*buf = strdup(repr);
|
||||
assert(*buf);
|
||||
|
Loading…
Reference in New Issue
Block a user