]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
Convert harmful calls to strncpy() to strlcpy()
authorPhil Sutter <phil@nwl.cc>
Fri, 1 Sep 2017 16:52:53 +0000 (18:52 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 1 Sep 2017 19:10:54 +0000 (12:10 -0700)
This patch converts spots where manual buffer termination was missing to
strlcpy() since that does what is needed.

Signed-off-by: Phil Sutter <phil@nwl.cc>
genl/ctrl.c
ip/ipvrf.c
ip/xfrm_state.c

index 6abd52582d0d3645139afe84ccbd0d429713b02e..448988eb90e2b4a9307b4bfefa7c53a0b0f05b39 100644 (file)
@@ -313,7 +313,7 @@ static int ctrl_list(int cmd, int argc, char **argv)
 
                if (matches(*argv, "name") == 0) {
                        NEXT_ARG();
-                       strncpy(d, *argv, sizeof (d) - 1);
+                       strlcpy(d, *argv, sizeof(d));
                        addattr_l(nlh, 128, CTRL_ATTR_FAMILY_NAME,
                                  d, strlen(d) + 1);
                } else if (matches(*argv, "id") == 0) {
index b74c501e0970c798053a3f50b79cc3352759c495..f9277e1e66bdf84eb9b0fb1946df53f72f8443a5 100644 (file)
@@ -74,7 +74,7 @@ static int vrf_identify(pid_t pid, char *name, size_t len)
                        if (end)
                                *end = '\0';
 
-                       strncpy(name, vrf, len - 1);
+                       strlcpy(name, vrf, len);
                        break;
                }
        }
index e11c93bf1c3b5dc55dce5de301edb50480ecc805..4483fb8f71d2c162b16ec0dfba98be8189dcb425 100644 (file)
@@ -125,7 +125,7 @@ static int xfrm_algo_parse(struct xfrm_algo *alg, enum xfrm_attr_type_t type,
        fprintf(stderr, "warning: ALGO-NAME/ALGO-KEYMAT values will be sent to the kernel promiscuously! (verifying them isn't implemented yet)\n");
 #endif
 
-       strncpy(alg->alg_name, name, sizeof(alg->alg_name));
+       strlcpy(alg->alg_name, name, sizeof(alg->alg_name));
 
        if (slen > 2 && strncmp(key, "0x", 2) == 0) {
                /* split two chars "0x" from the top */