From: Phil Sutter Date: Fri, 1 Sep 2017 16:52:56 +0000 (+0200) Subject: lnstat_util: Make sure buffer is NUL-terminated X-Git-Tag: v4.13.0~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc4a57b87990b30c85fdf0efbc1f8f219466daf4;p=thirdparty%2Fiproute2.git 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 --- diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c index ec19238c2..c2dc42ec1 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); }