]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lnstat_util: Make sure buffer is NUL-terminated
authorPhil Sutter <phil@nwl.cc>
Fri, 1 Sep 2017 16:52:56 +0000 (18:52 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 1 Sep 2017 19:10:54 +0000 (12:10 -0700)
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

index ec19238c24b94807acda80645d0d6654efb908dc..c2dc42ec1ff12a4848691d2e1ea2b642f0aa9631 100644 (file)
@@ -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);
 }