]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
extensions: libipt_ttl: Sanitize xlate callback
authorPhil Sutter <phil@nwl.cc>
Wed, 16 Nov 2022 12:09:16 +0000 (13:09 +0100)
committerPhil Sutter <phil@nwl.cc>
Thu, 24 Nov 2022 09:24:06 +0000 (10:24 +0100)
Catch unexpected values in info->mode, also fix indenting.

Fixes: 1b320a1a1dc1f ("extensions: libipt_ttl: Add translation to nft")
Signed-off-by: Phil Sutter <phil@nwl.cc>
extensions/libipt_ttl.c

index 6bdd2196180913ee632a071a69cd7eb1c0ff9fbc..86ba554ef92a87e068861690b6f7cfe925e57ed3 100644 (file)
@@ -106,7 +106,7 @@ static int ttl_xlate(struct xt_xlate *xl,
        const struct ipt_ttl_info *info =
                (struct ipt_ttl_info *) params->match->data;
 
-               switch (info->mode) {
+       switch (info->mode) {
                case IPT_TTL_EQ:
                        xt_xlate_add(xl, "ip ttl");
                        break;
@@ -121,7 +121,7 @@ static int ttl_xlate(struct xt_xlate *xl,
                        break;
                default:
                        /* Should not happen. */
-                       break;
+                       return 0;
        }
 
        xt_xlate_add(xl, " %u", info->ttl);