From: Stephen Hemminger Date: Wed, 28 Jun 2023 23:34:01 +0000 (-0700) Subject: ct: check for invalid proto X-Git-Tag: v6.5.0~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ac6d95a8465e7d41762fa493ec271ac4584aa0af;p=thirdparty%2Fiproute2.git ct: check for invalid proto Previously since proto was __u8 an invalid proto would be allowed. Gcc warns about never true conditional since __u8 can never be negative. Signed-off-by: Stephen Hemminger --- diff --git a/tc/m_ct.c b/tc/m_ct.c index 3e2491b3d..8c4714897 100644 --- a/tc/m_ct.c +++ b/tc/m_ct.c @@ -161,7 +161,8 @@ static int ct_parse_mark(char *str, struct nlmsghdr *n) static int ct_parse_helper(char *str, struct nlmsghdr *n) { char f[32], p[32], name[32]; - __u8 family, proto; + __u8 family; + int proto; if (strlen(str) >= 32 || sscanf(str, "%[^-]-%[^-]-%[^-]", f, p, name) != 3) @@ -172,6 +173,7 @@ static int ct_parse_helper(char *str, struct nlmsghdr *n) family = AF_INET6; else return -1; + proto = inet_proto_a2n(p); if (proto < 0) return -1;