pknock: add_rule must happen after info struct checks

This avoids unnecessarily creating pknock rules if there is an error
with any of the match parameters.
This commit is contained in:
Jan Engelhardt
2009-10-07 00:40:19 +02:00
parent c2c86f4b3d
commit 204b612e23

View 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;
}