The code here was doing strncpy() in a way that causes gcc 10
warning about possible string overflow. Just use strlcpy() which
will null terminate and bound the string as expected.
This has existed since start of git era so no Fixes tag.
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
buf[strlen(buf)-1] = 0;
if (info_source[0] && strcmp(info_source, buf+1))
source_mismatch = 1;
- strncpy(info_source, buf+1, sizeof(info_source)-1);
+ strlcpy(info_source, buf+1, sizeof(info_source));
continue;
}
if ((n = malloc(sizeof(*n))) == NULL)
buf[strlen(buf)-1] = 0;
if (info_source[0] && strcmp(info_source, buf+1))
source_mismatch = 1;
- info_source[0] = 0;
- strncat(info_source, buf+1, sizeof(info_source)-1);
+ strlcpy(info_source, buf + 1, sizeof(info_source));
continue;
}
/* idbuf is as big as buf, so this is safe */