From: Stephen Hemminger Date: Fri, 21 Apr 2023 17:05:49 +0000 (-0700) Subject: lwtunnel: use sizeof() on segbuf X-Git-Tag: v6.3.0~12 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=067c8247fa07451816ea493e971da11319faa0f8;p=thirdparty%2Fiproute2.git lwtunnel: use sizeof() on segbuf Avoid assuming that segbuf is 1024 bytes. Use sizeof() in places where it is being updated. Signed-off-by: Stephen Hemminger --- diff --git a/ip/iproute_lwtunnel.c b/ip/iproute_lwtunnel.c index d3100234d..308178efe 100644 --- a/ip/iproute_lwtunnel.c +++ b/ip/iproute_lwtunnel.c @@ -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();