From: Harald Welte Date: Tue, 16 Oct 2001 09:40:13 +0000 (+0000) Subject: fix bug in iptables-save, ocurring with targets without save() function. X-Git-Tag: v1.2.4~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=31098adc568dafa3e1e361f830a2dc514c107c8d;p=thirdparty%2Fiptables.git fix bug in iptables-save, ocurring with targets without save() function. Debian Bug #113011 --- diff --git a/iptables-save.c b/iptables-save.c index aa3b69af..bf75d5e0 100644 --- a/iptables-save.c +++ b/iptables-save.c @@ -192,14 +192,22 @@ static void print_rule(const struct ipt_entry *e, struct iptables_target *target = find_target(t->u.user.name, TRY_LOAD); - if (target) + if (!target) { + fprintf(stderr, "Can't find library for target `%s'\n", + t->u.user.name); + exit(1); + } + + if (target->save) target->save(&e->ip, t); else { - /* If some bits are non-zero, it implies we *need* - to understand it */ - if (t->u.target_size) { - fprintf(stderr, - "Can't find library for target `%s'\n", + /* If the target size is greater than ipt_entry_target + * there is something to be saved, we just don't know + * how to print it */ + if (t->u.target_size != + sizeof(struct ipt_entry_target)) { + fprintf(stderr, "Target `%s' is missing " + "save function\n", t->u.user.name); exit(1); }