[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230628233813.6564-5-stephen@networkplumber.org>
Date: Wed, 28 Jun 2023 16:38:12 -0700
From: Stephen Hemminger <stephen@...workplumber.org>
To: netdev@...r.kernel.org
Cc: Stephen Hemminger <stephen@...workplumber.org>
Subject: [PATCH iproute2 4/5] 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 <stephen@...workplumber.org>
---
tc/m_ct.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/tc/m_ct.c b/tc/m_ct.c
index 3e2491b3d192..8c471489778a 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;
--
2.39.2
Powered by blists - more mailing lists