]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: Check match/target size vs XT_ALIGN(size) at register time
authorSerhey Popovych <serhe.popovych@gmail.com>
Wed, 7 Mar 2018 09:10:41 +0000 (11:10 +0200)
committerFlorian Westphal <fw@strlen.de>
Fri, 27 Apr 2018 16:56:23 +0000 (18:56 +0200)
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>
libxtables/xtables.c

index afde394bb1e683b72217a34341db703a36e9f49d..857da8a6d9b8803335f6cc86fd44e3a4db3a122c 100644 (file)
@@ -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;