Blame SOURCES/0045-evaluate-Reject-quoted-strings-containing-only-wildc.patch

cf8614
From 805fe6f5c9c8f2af78d8e94bd6b5c33724df3c80 Mon Sep 17 00:00:00 2001
cf8614
From: Phil Sutter <psutter@redhat.com>
cf8614
Date: Tue, 18 May 2021 18:16:21 +0200
cf8614
Subject: [PATCH] evaluate: Reject quoted strings containing only wildcard
cf8614
cf8614
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1818117
cf8614
Upstream Status: nftables commit 032c9f745c6da
cf8614
cf8614
commit 032c9f745c6daab8c27176a95963b1c32b0a5d12
cf8614
Author: Phil Sutter <phil@nwl.cc>
cf8614
Date:   Thu Sep 24 17:38:45 2020 +0200
cf8614
cf8614
    evaluate: Reject quoted strings containing only wildcard
cf8614
cf8614
    Fix for an assertion fail when trying to match against an all-wildcard
cf8614
    interface name:
cf8614
cf8614
    | % nft add rule t c iifname '"*"'
cf8614
    | nft: expression.c:402: constant_expr_alloc: Assertion `(((len) + (8) - 1) / (8)) > 0' failed.
cf8614
    | zsh: abort      nft add rule t c iifname '"*"'
cf8614
cf8614
    Fix this by detecting the string in expr_evaluate_string() and returning
cf8614
    an error message:
cf8614
cf8614
    | % nft add rule t c iifname '"*"'
cf8614
    | Error: All-wildcard strings are not supported
cf8614
    | add rule t c iifname "*"
cf8614
    |                      ^^^
cf8614
cf8614
    While being at it, drop the 'datalen >= 1' clause from the following
cf8614
    conditional as together with the added check for 'datalen == 0', all
cf8614
    possible other values have been caught already.
cf8614
---
cf8614
 src/evaluate.c | 7 +++++--
cf8614
 1 file changed, 5 insertions(+), 2 deletions(-)
cf8614
cf8614
diff --git a/src/evaluate.c b/src/evaluate.c
cf8614
index a966ed4..0181750 100644
cf8614
--- a/src/evaluate.c
cf8614
+++ b/src/evaluate.c
cf8614
@@ -321,8 +321,11 @@ static int expr_evaluate_string(struct eval_ctx *ctx, struct expr **exprp)
cf8614
 		return 0;
cf8614
 	}
cf8614
 
cf8614
-	if (datalen >= 1 &&
cf8614
-	    data[datalen - 1] == '\\') {
cf8614
+	if (datalen == 0)
cf8614
+		return expr_error(ctx->msgs, expr,
cf8614
+				  "All-wildcard strings are not supported");
cf8614
+
cf8614
+	if (data[datalen - 1] == '\\') {
cf8614
 		char unescaped_str[data_len];
cf8614
 
cf8614
 		memset(unescaped_str, 0, sizeof(unescaped_str));
cf8614
-- 
cf8614
1.8.3.1
cf8614