diff mbox series

[xtables-compat,3/3] xtables-compat: fix bogus error with -X and no user-defined chains

Message ID 20180507152054.23589-3-pablo@netfilter.org
State Accepted
Delegated to: Pablo Neira
Headers show
Series [xtables-compat,v2,1/3] xtables-compat-restore: flush rules and delete user-defined chains | expand

Commit Message

Pablo Neira Ayuso May 7, 2018, 3:20 p.m. UTC
# iptables-compat -X
 iptables: No chain/target/match by that name.

While it should display no error message at all.

Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 iptables/nft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/iptables/nft.c b/iptables/nft.c
index bbea5f21c398..10befea5200b 100644
--- a/iptables/nft.c
+++ b/iptables/nft.c
@@ -1547,7 +1547,7 @@  next:
 err:
 
 	/* chain not found */
-	if (deleted_ctr == 0) {
+	if (chain != NULL && deleted_ctr == 0) {
 		ret = -1;
 		errno = ENOENT;
 	}