]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
ct: check for invalid proto
authorStephen Hemminger <stephen@networkplumber.org>
Wed, 28 Jun 2023 23:34:01 +0000 (16:34 -0700)
committerStephen Hemminger <stephen@networkplumber.org>
Wed, 28 Jun 2023 23:34:01 +0000 (16:34 -0700)
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@networkplumber.org>
tc/m_ct.c

index 3e2491b3d192f99afbab680379c657f91e28ed78..8c471489778a1c5efb7ef38205a5b67d56bbb979 100644 (file)
--- 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;