[nft PATCH v2 4/4] xt: Detect xlate callback failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If an extension's xlate callback returns 0, translation is at least
incomplete. Discard the result and resort to opaque dump format in this
case.

Signed-off-by: Phil Sutter <phil@xxxxxx>
---
 src/xt.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/xt.c b/src/xt.c
index e3063612c353e..178761a42018d 100644
--- a/src/xt.c
+++ b/src/xt.c
@@ -116,6 +116,7 @@ static bool xt_stmt_xlate_match(const struct stmt *stmt, void *entry,
 	};
 	struct xtables_match *mt;
 	struct xt_entry_match *m;
+	int rc;
 
 	mt = xtables_find_match(stmt->xt.name, XTF_TRY_LOAD, NULL);
 	if (!mt) {
@@ -132,10 +133,10 @@ static bool xt_stmt_xlate_match(const struct stmt *stmt, void *entry,
 	memcpy(&m->data, stmt->xt.info, stmt->xt.infolen);
 
 	params.match = m;
-	mt->xlate(xl, &params);
+	rc = mt->xlate(xl, &params);
 
 	xfree(m);
-	return true;
+	return rc != 0;
 }
 
 static bool xt_stmt_xlate_target(const struct stmt *stmt, void *entry,
@@ -149,6 +150,7 @@ static bool xt_stmt_xlate_target(const struct stmt *stmt, void *entry,
 	};
 	struct xtables_target *tg;
 	struct xt_entry_target *t;
+	int rc;
 
 	tg = xtables_find_target(stmt->xt.name, XTF_TRY_LOAD);
 	if (!tg) {
@@ -166,10 +168,10 @@ static bool xt_stmt_xlate_target(const struct stmt *stmt, void *entry,
 	strcpy(t->u.user.name, tg->name);
 
 	params.target = t;
-	tg->xlate(xl, &params);
+	rc = tg->xlate(xl, &params);
 
 	xfree(t);
-	return true;
+	return rc != 0;
 }
 #endif
 
-- 
2.38.0




[Index of Archives]     [Netfitler Users]     [Berkeley Packet Filter]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux