]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lwtunnel: use sizeof() on segbuf
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 21 Apr 2023 17:05:49 +0000 (10:05 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 21 Apr 2023 17:05:49 +0000 (10:05 -0700)
Avoid assuming that segbuf is 1024 bytes. Use sizeof() in
places where it is being updated.

Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
ip/iproute_lwtunnel.c

index d3100234d2411532d2b131165018b61d288545e9..308178efe0547c6b378605d6039fe23bab4ce5d3 100644 (file)
@@ -961,7 +961,7 @@ static int parse_encap_seg6(struct rtattr *rta, size_t len, int *argcp,
                                invarg("\"segs\" provided before \"mode\"\n",
                                       *argv);
 
-                       strlcpy(segbuf, *argv, 1024);
+                       strlcpy(segbuf, *argv, sizeof(segbuf));
                } else if (strcmp(*argv, "hmac") == 0) {
                        NEXT_ARG();
                        if (hmac_ok++)
@@ -1047,7 +1047,7 @@ static int parse_encap_rpl(struct rtattr *rta, size_t len, int *argcp,
                        if (segs_ok++)
                                duparg2("segs", *argv);
 
-                       strlcpy(segbuf, *argv, 1024);
+                       strlcpy(segbuf, *argv, sizeof(segbuf));
                } else {
                        break;
                }
@@ -1468,7 +1468,7 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
                        NEXT_ARG();
                        if (segs_ok++)
                                duparg2("segs", *argv);
-                       strlcpy(segbuf, *argv, 1024);
+                       strlcpy(segbuf, *argv, sizeof(segbuf));
                        if (!NEXT_ARG_OK())
                                break;
                        NEXT_ARG();