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

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