]> git.ipfire.org Git - thirdparty/xtables-addons.git/commitdiff
pknock: add_rule must happen after info struct checks
authorJan Engelhardt <jengelh@medozas.de>
Tue, 6 Oct 2009 22:40:19 +0000 (00:40 +0200)
committerJan Engelhardt <jengelh@medozas.de>
Tue, 6 Oct 2009 23:12:03 +0000 (01:12 +0200)
This avoids unnecessarily creating pknock rules if there is an error
with any of the match parameters.

extensions/xt_pknock.c

index 97ccec3b37fc028a753d89773b5e911093785948..bb65312ee42a26e359aebbdfa7a37f57bbaa6f86 100644 (file)
@@ -1034,9 +1034,6 @@ static bool pknock_mt_check(const struct xt_mtchk_param *par)
                get_random_bytes(&ipt_pknock_hash_rnd, sizeof (ipt_pknock_hash_rnd));
        }
 
-       if (!add_rule(info))
-               RETURN_ERR("add_rule() error in checkentry() function.\n");
-
        if (!(info->option & XT_PKNOCK_NAME))
                RETURN_ERR("You must specify --name option.\n");
 
@@ -1081,6 +1078,9 @@ static bool pknock_mt_check(const struct xt_mtchk_param *par)
        }
 #endif
 
+       if (!add_rule(info))
+               RETURN_ERR("add_rule() error in checkentry() function.\n");
+
        return true;
 }