124 Star 0 Fork 19

src-openEuler/jq

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
CVE-2024-53427.patch 2.52 KB
一键复制 编辑 原始数据 按行查看 历史
starlet_dx 提交于 2025-03-07 11:40 +08:00 . Fix CVE-2024-53427
From a09a4dfd55e6c24d04b35062ccfe4509748b1dd3 Mon Sep 17 00:00:00 2001
From: itchyny <itchyny@cybozu.co.jp>
Date: Wed, 5 Mar 2025 07:43:54 +0900
Subject: [PATCH] Reject NaN with payload while parsing JSON
This commit drops support for parsing NaN with payload in JSON like
`NaN123` and fixes CVE-2024-53427. Other JSON extensions like `NaN` and
`Infinity` are still supported. Fixes #3023, fixes #3196, fixes #3246.
Origin: https://github.com/jqlang/jq/commit/a09a4dfd55e6c24d04b35062ccfe4509748b1dd3
---
src/jv.c | 5 +++++
tests/jq.test | 14 ++++++++++----
tests/shtest | 5 -----
3 files changed, 15 insertions(+), 9 deletions(-)
diff --git a/src/jv.c b/src/jv.c
index 9329eae..e26f74d 100644
--- a/src/jv.c
+++ b/src/jv.c
@@ -587,6 +587,11 @@ static jv jvp_literal_number_new(const char * literal) {
return JV_INVALID;
}
if (decNumberIsNaN(&n->num_decimal)) {
+ // Reject NaN with payload.
+ if (n->num_decimal.digits > 1 || *n->num_decimal.lsu != 0) {
+ jv_mem_free(n);
+ return JV_INVALID;
+ }
jv_mem_free(n);
return jv_number(NAN);
}
diff --git a/tests/jq.test b/tests/jq.test
index 7036df2..d052b22 100644
--- a/tests/jq.test
+++ b/tests/jq.test
@@ -1938,11 +1938,17 @@ tojson | fromjson
{"a":nan}
{"a":null}
-# also "nan with payload" #2985
-fromjson | isnan
-"nan1234"
+# NaN with payload is not parsed
+.[] | try (fromjson | isnan) catch .
+["NaN","-NaN","NaN1","NaN10","NaN100","NaN1000","NaN10000","NaN100000"]
true
-
+true
+"Invalid numeric literal at EOF at line 1, column 4 (while parsing 'NaN1')"
+"Invalid numeric literal at EOF at line 1, column 5 (while parsing 'NaN10')"
+"Invalid numeric literal at EOF at line 1, column 6 (while parsing 'NaN100')"
+"Invalid numeric literal at EOF at line 1, column 7 (while parsing 'NaN1000')"
+"Invalid numeric literal at EOF at line 1, column 8 (while parsing 'NaN10000')"
+"Invalid numeric literal at EOF at line 1, column 9 (while parsing 'NaN100000')"
# calling input/0, or debug/0 in a test doesn't crash jq
diff --git a/tests/shtest b/tests/shtest
index 14aafbf..a471889 100755
--- a/tests/shtest
+++ b/tests/shtest
@@ -594,11 +594,6 @@ if ! x=$($JQ -n "1 # foo$cr + 2") || [ "$x" != 1 ]; then
exit 1
fi
-# CVE-2023-50268: No stack overflow comparing a nan with a large payload
-$VALGRIND $Q $JQ '1 != .' <<\EOF >/dev/null
-Nan4000
-EOF
-
# Allow passing the inline jq script before -- #2919
if ! r=$($JQ --args -rn -- '$ARGS.positional[0]' bar) || [ "$r" != bar ]; then
echo "passing the inline script after -- didn't work"
--
2.48.1
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/src-openeuler/jq.git
git@gitee.com:src-openeuler/jq.git
src-openeuler
jq
jq
master

搜索帮助