From 31098adc568dafa3e1e361f830a2dc514c107c8d Mon Sep 17 00:00:00 2001 From: Harald Welte Date: Tue, 16 Oct 2001 09:40:13 +0000 Subject: fix bug in iptables-save, ocurring with targets without save() function. Debian Bug #113011 --- iptables-save.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) (limited to 'iptables-save.c') 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); } -- cgit v1.2.3