Blob Blame History Raw
From 7c8016f4afb2c4ec5c717b1c830c655318a0c561 Mon Sep 17 00:00:00 2001
From: Phil Sutter <psutter@redhat.com>
Date: Fri, 12 May 2017 12:51:22 +0200
Subject: [PATCH] tests: stricter string attribute validation

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1441084
Upstream Status: libnftnl commit 57468cfa7916a

commit 57468cfa7916aa6e21c977d1ddb6d0a0ad27edf7
Author: Pablo Neira Ayuso <pablo@netfilter.org>
Date:   Wed Jun 15 13:41:06 2016 +0200

    tests: stricter string attribute validation

    In nft-expr_lookup-test.c, check for the strings instead of size.

    Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
 tests/nft-expr_lookup-test.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/tests/nft-expr_lookup-test.c b/tests/nft-expr_lookup-test.c
index ad028e9..2ca431b 100644
--- a/tests/nft-expr_lookup-test.c
+++ b/tests/nft-expr_lookup-test.c
@@ -30,18 +30,15 @@ static void print_err(const char *msg)
 static void cmp_nftnl_expr(struct nftnl_expr *rule_a,
 			      struct nftnl_expr *rule_b)
 {
-	uint32_t data_lena, data_lenb;
-
 	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_SREG) !=
 	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOPUP_SREG))
 		print_err("Expr NFTNL_EXPR_LOOkUP_SREG mismatches");
 	if (nftnl_expr_get_u32(rule_a, NFTNL_EXPR_LOOKUP_DREG) !=
 	    nftnl_expr_get_u32(rule_b, NFTNL_EXPR_LOOPUP_DREG))
 		print_err("Expr NFTNL_EXPR_LOOkUP_DREG mismatches");
-	nftnl_expr_get(rule_a, NFTNL_EXPR_LOOKUP_SET, &data_lena);
-	nftnl_expr_get(rule_b, NFTNL_EXPR_LOOKUP_SET, &data_lenb);
-	if (data_lena != data_lenb)
-		print_err("Expr NFTNL_EXPR_LOOKUP_SET size mismatches");
+	if (strcmp(nftnl_expr_get_str(rule_a, NFTNL_EXPR_LOOKUP_SET),
+		   nftnl_expr_get_str(rule_b, NFTNL_EXPR_LOOKUP_SET)))
+		print_err("Expr NFTNL_EXPR_LOOKUP_SET mismatches");
 }
 
 int main(int argc, char *argv[])
-- 
1.8.3.1