Message ID | 20170901165256.21459-7-phil@nwl.cc |
---|---|
State | Accepted, archived |
Delegated to: | stephen hemminger |
Headers | show |
Series | strlcpy() and strlcat() for iproute2 | expand |
diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c index ec19238c24b94..c2dc42ec1ff12 100644 --- a/misc/lnstat_util.c +++ b/misc/lnstat_util.c @@ -150,7 +150,8 @@ static int lnstat_scan_compat_rtstat_fields(struct lnstat_file *lf) { char buf[FGETS_BUF_SIZE]; - strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf)-1); + strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf) - 1); + buf[sizeof(buf) - 1] = '\0'; return __lnstat_scan_fields(lf, buf); }
Can't use strlcpy() here since lnstat is not linked against libutil. While being at it, fix coding style in that chunk as well. Signed-off-by: Phil Sutter <phil@nwl.cc> --- misc/lnstat_util.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)