|
|
99be8f |
From 9556150792daf8f2fbea934bcb77b4b74a21b2e1 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] Convert harmful calls to strncpy() to strlcpy()
|
|
|
99be8f |
|
|
|
99be8f |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465646
|
|
|
99be8f |
Upstream Status: iproute2.git commit 532b8874fe545
|
|
|
99be8f |
|
|
|
99be8f |
commit 532b8874fe545acaa8d45c4dd3b54b8f3bb41d9f
|
|
|
99be8f |
Author: Phil Sutter <phil@nwl.cc>
|
|
|
99be8f |
Date: Fri Sep 1 18:52:53 2017 +0200
|
|
|
99be8f |
|
|
|
99be8f |
Convert harmful calls to strncpy() to strlcpy()
|
|
|
99be8f |
|
|
|
99be8f |
This patch converts spots where manual buffer termination was missing to
|
|
|
99be8f |
strlcpy() since that does what is needed.
|
|
|
99be8f |
|
|
|
99be8f |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
99be8f |
---
|
|
|
99be8f |
genl/ctrl.c | 2 +-
|
|
|
99be8f |
ip/ipvrf.c | 2 +-
|
|
|
99be8f |
ip/xfrm_state.c | 2 +-
|
|
|
99be8f |
3 files changed, 3 insertions(+), 3 deletions(-)
|
|
|
99be8f |
|
|
|
99be8f |
diff --git a/genl/ctrl.c b/genl/ctrl.c
|
|
|
99be8f |
index 21e857cfcfc25..a6d31b04e5679 100644
|
|
|
99be8f |
--- a/genl/ctrl.c
|
|
|
99be8f |
+++ b/genl/ctrl.c
|
|
|
99be8f |
@@ -317,7 +317,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
|
|
|
99be8f |
|
|
|
99be8f |
if (matches(*argv, "name") == 0) {
|
|
|
99be8f |
NEXT_ARG();
|
|
|
99be8f |
- strncpy(d, *argv, sizeof (d) - 1);
|
|
|
99be8f |
+ strlcpy(d, *argv, sizeof(d));
|
|
|
99be8f |
addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME,
|
|
|
99be8f |
d, strlen(d) + 1);
|
|
|
99be8f |
} else if (matches(*argv, "id") == 0) {
|
|
|
99be8f |
diff --git a/ip/ipvrf.c b/ip/ipvrf.c
|
|
|
99be8f |
index f58c8df728265..406cddbcd44ca 100644
|
|
|
99be8f |
--- a/ip/ipvrf.c
|
|
|
99be8f |
+++ b/ip/ipvrf.c
|
|
|
99be8f |
@@ -71,7 +71,7 @@ static int vrf_identify(pid_t pid, char *name, size_t len)
|
|
|
99be8f |
if (end)
|
|
|
99be8f |
*end = '\0';
|
|
|
99be8f |
|
|
|
99be8f |
- strncpy(name, vrf, len - 1);
|
|
|
99be8f |
+ strlcpy(name, vrf, len);
|
|
|
99be8f |
break;
|
|
|
99be8f |
}
|
|
|
99be8f |
}
|
|
|
99be8f |
diff --git a/ip/xfrm_state.c b/ip/xfrm_state.c
|
|
|
99be8f |
index 04ed3492ad3b5..2222737cdd98d 100644
|
|
|
99be8f |
--- a/ip/xfrm_state.c
|
|
|
99be8f |
+++ b/ip/xfrm_state.c
|
|
|
99be8f |
@@ -123,7 +123,7 @@ static int xfrm_algo_parse(struct xfrm_algo *alg, enum xfrm_attr_type_t type,
|
|
|
99be8f |
fprintf(stderr, "warning: ALGO-NAME/ALGO-KEYMAT values will be sent to the kernel promiscuously! (verifying them isn't implemented yet)\n");
|
|
|
99be8f |
#endif
|
|
|
99be8f |
|
|
|
99be8f |
- strncpy(alg->alg_name, name, sizeof(alg->alg_name));
|
|
|
99be8f |
+ strlcpy(alg->alg_name, name, sizeof(alg->alg_name));
|
|
|
99be8f |
|
|
|
99be8f |
if (slen > 2 && strncmp(key, "0x", 2) == 0) {
|
|
|
99be8f |
/* split two chars "0x" from the top */
|
|
|
99be8f |
--
|
|
|
d30c09 |
2.21.0
|
|
|
99be8f |
|