Blame SOURCES/0122-lnstat_util-Make-sure-buffer-is-NUL-terminated.patch

99be8f
From ed508c9ee5991655039d2b080191b1c70680b5c8 Mon Sep 17 00:00:00 2001
99be8f
From: Andrea Claudi <aclaudi@redhat.com>
99be8f
Date: Mon, 29 Apr 2019 20:09:12 +0200
99be8f
Subject: [PATCH] lnstat_util: Make sure buffer is NUL-terminated
99be8f
99be8f
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
99be8f
Upstream Status: iproute2.git commit bc4a57b87990b
99be8f
99be8f
commit bc4a57b87990b30c85fdf0efbc1f8f219466daf4
99be8f
Author: Phil Sutter <phil@nwl.cc>
99be8f
Date:   Fri Sep 1 18:52:56 2017 +0200
99be8f
99be8f
    lnstat_util: Make sure buffer is NUL-terminated
99be8f
99be8f
    Can't use strlcpy() here since lnstat is not linked against libutil.
99be8f
99be8f
    While being at it, fix coding style in that chunk as well.
99be8f
99be8f
    Signed-off-by: Phil Sutter <phil@nwl.cc>
99be8f
---
99be8f
 misc/lnstat_util.c | 3 ++-
99be8f
 1 file changed, 2 insertions(+), 1 deletion(-)
99be8f
99be8f
diff --git a/misc/lnstat_util.c b/misc/lnstat_util.c
99be8f
index ec19238c24b94..c2dc42ec1ff12 100644
99be8f
--- a/misc/lnstat_util.c
99be8f
+++ b/misc/lnstat_util.c
99be8f
@@ -150,7 +150,8 @@ static int lnstat_scan_compat_rtstat_fields(struct lnstat_file *lf)
99be8f
 {
99be8f
 	char buf[FGETS_BUF_SIZE];
99be8f
 
99be8f
-	strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf)-1);
99be8f
+	strncpy(buf, RTSTAT_COMPAT_LINE, sizeof(buf) - 1);
99be8f
+	buf[sizeof(buf) - 1] = '\0';
99be8f
 
99be8f
 	return __lnstat_scan_fields(lf, buf);
99be8f
 }
99be8f
-- 
d30c09
2.21.0
99be8f