|
|
3a00e5 |
From cf2d347fe9cc384d4453a2a379e0dde8b97d081f Mon Sep 17 00:00:00 2001
|
|
|
3a00e5 |
From: Phil Sutter <phil@nwl.cc>
|
|
|
3a00e5 |
Date: Thu, 28 Jan 2021 01:09:56 +0100
|
|
|
3a00e5 |
Subject: [PATCH] ebtables: Exit gracefully on invalid table names
|
|
|
3a00e5 |
|
|
|
3a00e5 |
Users are able to cause program abort by passing a table name that
|
|
|
3a00e5 |
doesn't exist:
|
|
|
3a00e5 |
|
|
|
3a00e5 |
| # ebtables-nft -t dummy -P INPUT ACCEPT
|
|
|
3a00e5 |
| ebtables: nft-cache.c:455: fetch_chain_cache: Assertion `t' failed.
|
|
|
3a00e5 |
| Aborted
|
|
|
3a00e5 |
|
|
|
3a00e5 |
Avoid this by checking table existence just like iptables-nft does upon
|
|
|
3a00e5 |
parsing '-t' optarg. Since the list of tables is known and fixed,
|
|
|
3a00e5 |
checking the given name's length is pointless. So just drop that check
|
|
|
3a00e5 |
in return.
|
|
|
3a00e5 |
|
|
|
3a00e5 |
With this patch in place, output looks much better:
|
|
|
3a00e5 |
|
|
|
3a00e5 |
| # ebtables-nft -t dummy -P INPUT ACCEPT
|
|
|
3a00e5 |
| ebtables v1.8.7 (nf_tables): table 'dummy' does not exist
|
|
|
3a00e5 |
| Perhaps iptables or your kernel needs to be upgraded.
|
|
|
3a00e5 |
|
|
|
3a00e5 |
Signed-off-by: Phil Sutter <phil@nwl.cc>
|
|
|
3a00e5 |
(cherry picked from commit 30c1d443896311e69762d6b51b63908ec602574f)
|
|
|
3a00e5 |
---
|
|
|
3a00e5 |
iptables/xtables-eb.c | 8 ++++----
|
|
|
3a00e5 |
1 file changed, 4 insertions(+), 4 deletions(-)
|
|
|
3a00e5 |
|
|
|
3a00e5 |
diff --git a/iptables/xtables-eb.c b/iptables/xtables-eb.c
|
|
|
3a00e5 |
index cfa9317c78e94..5bb34d6d292a9 100644
|
|
|
3a00e5 |
--- a/iptables/xtables-eb.c
|
|
|
3a00e5 |
+++ b/iptables/xtables-eb.c
|
|
|
3a00e5 |
@@ -914,10 +914,10 @@ print_zero:
|
|
|
3a00e5 |
xtables_error(PARAMETER_PROBLEM,
|
|
|
3a00e5 |
"The -t option (seen in line %u) cannot be used in %s.\n",
|
|
|
3a00e5 |
line, xt_params->program_name);
|
|
|
3a00e5 |
- if (strlen(optarg) > EBT_TABLE_MAXNAMELEN - 1)
|
|
|
3a00e5 |
- xtables_error(PARAMETER_PROBLEM,
|
|
|
3a00e5 |
- "Table name length cannot exceed %d characters",
|
|
|
3a00e5 |
- EBT_TABLE_MAXNAMELEN - 1);
|
|
|
3a00e5 |
+ if (!nft_table_builtin_find(h, optarg))
|
|
|
3a00e5 |
+ xtables_error(VERSION_PROBLEM,
|
|
|
3a00e5 |
+ "table '%s' does not exist",
|
|
|
3a00e5 |
+ optarg);
|
|
|
3a00e5 |
*table = optarg;
|
|
|
3a00e5 |
table_set = true;
|
|
|
3a00e5 |
break;
|
|
|
3a00e5 |
--
|
|
|
3a00e5 |
2.31.1
|
|
|
3a00e5 |
|