naccyde / rpms / iproute

Forked from rpms/iproute 7 months ago
Clone

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

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