Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Timeout error found in cJSON_Compare

未关闭
#950 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
48/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
停滞
技术栈
c
领域
api

调研方向

首先针对 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

DaveGamble/cJSON 的其他 Issue

查看 DaveGamble/cJSON 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。