diff options
author | Serhey Popovych <serhe.popovych@gmail.com> | 2018-03-07 11:10:41 +0200 |
---|---|---|
committer | Florian Westphal <fw@strlen.de> | 2018-04-27 18:56:23 +0200 |
commit | e3bb24cbaacd308c0f0b7840f092e230f77e9587 (patch) | |
tree | 43660b98c5084d1dfc107d0d82e8d1e3cc21fc07 | |
parent | 3b2530ce7a0d6aa3bee687bf0167bb4908c7b798 (diff) |
xtables: Check match/target size vs XT_ALIGN(size) at register time
Size is known at xtables_register_match()/xtables_register_target()
calls: no need to defer it to final registration steps.
Signed-off-by: Serhey Popovych <serhe.popovych@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
-rw-r--r-- | libxtables/xtables.c | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/libxtables/xtables.c b/libxtables/xtables.c index afde394b..857da8a6 100644 --- a/libxtables/xtables.c +++ b/libxtables/xtables.c @@ -857,6 +857,14 @@ void xtables_register_match(struct xtables_match *me) xt_params->program_name, me->name, me->revision); exit(1); } + + if (me->size != XT_ALIGN(me->size)) { + fprintf(stderr, "%s: match \"%s\" has invalid size %u.\n", + xt_params->program_name, me->name, + (unsigned int)me->size); + exit(1); + } + if (strcmp(me->version, XTABLES_VERSION) != 0) { fprintf(stderr, "%s: match \"%s\" has version \"%s\", " "but \"%s\" is required.\n", @@ -985,13 +993,6 @@ static bool xtables_fully_register_pending_match(struct xtables_match *me) *i = old->next; } - if (me->size != XT_ALIGN(me->size)) { - fprintf(stderr, "%s: match `%s' has invalid size %u.\n", - xt_params->program_name, me->name, - (unsigned int)me->size); - exit(1); - } - /* Append to list. */ for (i = &xtables_matches; *i; i = &(*i)->next); me->next = NULL; @@ -1023,6 +1024,14 @@ void xtables_register_target(struct xtables_target *me) xt_params->program_name, me->name, me->revision); exit(1); } + + if (me->size != XT_ALIGN(me->size)) { + fprintf(stderr, "%s: target \"%s\" has invalid size %u.\n", + xt_params->program_name, me->name, + (unsigned int)me->size); + exit(1); + } + if (strcmp(me->version, XTABLES_VERSION) != 0) { fprintf(stderr, "%s: target \"%s\" has version \"%s\", " "but \"%s\" is required.\n", @@ -1094,13 +1103,6 @@ static bool xtables_fully_register_pending_target(struct xtables_target *me) *i = old->next; } - if (me->size != XT_ALIGN(me->size)) { - fprintf(stderr, "%s: target `%s' has invalid size %u.\n", - xt_params->program_name, me->name, - (unsigned int)me->size); - exit(1); - } - /* Prepend to list. */ me->next = xtables_targets; xtables_targets = me; |