Timeout error found in cJSON_Compare
还没有人认领这个 Issue。
评估
调研方向
首先针对 cJSON_Parse、cJSON_Duplicate 和 cJSON_Compare 编译并运行最小化的 POC,然后跟踪比较在嵌套对象中的停止位置。该 issue 未指定源文件或回归测试;完成的标准是 POC 在不超时的情况下完成,同时保持正确的比较行为。
由索引模型根据 Issue 内容生成。
描述
Dear developers,
I found a timeout error in the cJSON_Compare API when fuzzing the cJSON library.
The following is the minimized POC code:
#include <fuzzer/FuzzedDataProvider.h>
#include <cstdint>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include "cjson/cJSON.h"
int main() {
bool case_sensitive_operations = true;
bool recurse_duplicate = true;
uint8_t operation_selector = 5;
// Consume variable-size data for JSON strings and object keys
std::string initial_json = "{\t\"%q\":{\t\"ky\"\001:{\"e\"\t:{\"ey\"\001:{\"\377\377\":{\"e\":{\"\037\"\001:{\"e\":{\"k\"\001:{\"e\"\t:{\t\"\"\001:{\"\377\377\"\001:{\"y\"\001:{\"seye\"\t:{\t\"ke\"\001:{\"\377k\"\001:{\"ke8\"\001:{\t\"%v\"\t:{\t\"key\"\001:{\"\377\377\377\037\"\001:{\"e\"\t:{\t\"k\"\001:{\"e\"\t:{\t\"k\"\001:{\"\377\377\377\"\001:{\"y\"\t:{\t\"ey\"\001:{\"\377\377\377\037\"\001:{\"e\"\t:{\"k\"\001:{\"e\"\t:{\t\"k\":{}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}}{\".t\000\000\000\377\377\377}";
// Create initial JSON object using cJSON_Parse
cJSON* root = nullptr;
if (!initial_json.empty()) {
root = cJSON_Parse(initial_json.c_str());
}
// Create a duplicate of the object using cJSON_Duplicate
cJSON* duplicated_object = cJSON_Duplicate(root, recurse_duplicate ? 1 : 0);
// Compare the original and duplicate objects using cJSON_Compare
if (duplicated_object != nullptr) {
cJSON_bool comparison_result = cJSON_Compare(root, duplicated_object, case_sensitive_operations ? 1 : 0);
(void)comparison_result; // Suppress unused variable warning
}
cleanup:
// Clean up all allocated memory
if (root != nullptr) {
cJSON_Delete(root);
}
if (duplicated_object != nullptr) {
cJSON_Delete(duplicated_object);
}
return 0;
}
- 主要语言
- C
- 星标
- 13k
- 派生
- 3.5k
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
DaveGamble/cJSON 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 86/100
DaveGamble/cJSON#1094 · 1 个 reaction ·
-
难度 2/5 1-3 小时 新手友好度 68/100
DaveGamble/cJSON#1093 ·
-
Use-after-free in cJSONUtils_ApplyPatches when a patch removes the patch array可能已有人在做 @iliasabk 于 24 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1082 ·
-
Use-after-free in cJSON_ReplaceItemInObject when the key is the item's own name可能已有人在做 @iliasabk 于 25 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 82/100
DaveGamble/cJSON#1081 ·
-
buffer_skip_whitespace accepts every byte below 0x21 as whitespace可能已有人在做 @AetherAI3 于 36 天前认领。 未关闭
难度 2/5 1-3 小时 新手友好度 78/100
DaveGamble/cJSON#1074 ·
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 63/100
Xinyuan-LilyGO/T-Display-S3#352 · 3 条评论 ·
-
documentation severity/minor
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
docs: AGENTS.md has no rule against running deploy scripts into the owner's game install可能已有人在做 @thesprockee 今天认领。 未关闭
难度 1/5 1 小时以内 新手友好度 85/100
EchoTools/nevr-runtime#524 ·
维护者通常 1 天内回复
-
python library: btc_sign() sends antiklepto host nonce for taproot miniscript (tr() policy) inputs because is_taproot() only recognizes simple P2TR可能已有人在做 @benma-agent 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 75/100
BitBoxSwiss/bitbox02-firmware#2145 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 74/100
Genymobile/scrcpy#7097 ·
维护者通常 1 天内回复