]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
lwtunnel: fix warning from strncpy
authorStephen Hemminger <stephen@networkplumber.org>
Fri, 21 Apr 2023 17:01:51 +0000 (10:01 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Fri, 21 Apr 2023 17:01:51 +0000 (10:01 -0700)
The code for parsing segments in lwtunnel would trigger a warning
about strncpy if address sanitizer was enabled. Simpler to just
use strlcpy() like elsewhere.

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

index 9fcbdeac3e77b3530d4c2cf2fb74b43dcfdb8a23..d3100234d2411532d2b131165018b61d288545e9 100644 (file)
@@ -1468,8 +1468,7 @@ static int parse_encap_seg6local(struct rtattr *rta, size_t len, int *argcp,
                        NEXT_ARG();
                        if (segs_ok++)
                                duparg2("segs", *argv);
-                       strncpy(segbuf, *argv, 1024);
-                       segbuf[1023] = 0;
+                       strlcpy(segbuf, *argv, 1024);
                        if (!NEXT_ARG_OK())
                                break;
                        NEXT_ARG();