9 Star 1 Fork 30

src-openEuler/nftables

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
backport-evaluate-error-out-if-basetypes-are-different.patch 1.85 KB
一键复制 编辑 原始数据 按行查看 历史
Venland 提交于 2024-06-24 16:16 . backport upstream patch
From 45a4d4434742b425d019623812f2cce293033cdf Mon Sep 17 00:00:00 2001
From: Florian Westphal <fw@strlen.de>
Date: Mon, 4 Dec 2023 18:30:51 +0100
Subject: [PATCH] evaluate: error out if basetypes are different
prefer
binop_with_different_basetype_assert:3:29-35: Error: Binary operation (<<) with different base types (string vs integer) is not supported
oifname set ip9dscp << 26 | 0x10
^^^^^^^~~~~~~
to assertion failure.
Signed-off-by: Florian Westphal <fw@strlen.de>
---
src/evaluate.c | 7 +++++--
.../bogons/nft-f/binop_with_different_basetype_assert | 5 +++++
2 files changed, 10 insertions(+), 2 deletions(-)
create mode 100644 tests/shell/testcases/bogons/nft-f/binop_with_different_basetype_assert
diff --git a/src/evaluate.c b/src/evaluate.c
index b6670254..51ae276a 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1451,8 +1451,11 @@ static int expr_evaluate_binop(struct eval_ctx *ctx, struct expr **expr)
"for %s expressions",
sym, expr_name(right));
- /* The grammar guarantees this */
- assert(datatype_equal(expr_basetype(left), expr_basetype(right)));
+ if (!datatype_equal(expr_basetype(left), expr_basetype(right)))
+ return expr_binary_error(ctx->msgs, left, op,
+ "Binary operation (%s) with different base types "
+ "(%s vs %s) is not supported",
+ sym, expr_basetype(left)->name, expr_basetype(right)->name);
switch (op->op) {
case OP_LSHIFT:
diff --git a/tests/shell/testcases/bogons/nft-f/binop_with_different_basetype_assert b/tests/shell/testcases/bogons/nft-f/binop_with_different_basetype_assert
new file mode 100644
index 00000000..e8436008
--- /dev/null
+++ b/tests/shell/testcases/bogons/nft-f/binop_with_different_basetype_assert
@@ -0,0 +1,5 @@
+table ip t {
+ chain c {
+ oifname set ip9dscp << 26 | 0x10
+ }
+}
--
2.43.4
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/nftables.git
git@gitee.com:src-openeuler/nftables.git
src-openeuler
nftables
nftables
master

搜索帮助