summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Sutter <phil@nwl.cc>2017-09-01 18:52:56 +0200
committerStephen Hemminger <stephen@networkplumber.org>2017-09-01 12:10:54 -0700
commitbc4a57b87990b30c85fdf0efbc1f8f219466daf4 (patch)
treeca990345e97d9e60e19d4dcb3302f4c926d22dc4
parent9376314b49a47eb42ade3fc0d41cb51438f8dbc6 (diff)
lnstat_util: Make sure buffer is NUL-terminated
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>
-rw-r--r--misc/lnstat_util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c
index ec19238c..c2dc42ec 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);
}