Skip to content

fuzzing: add cjson_mutate_fuzzer for Duplicate/Compare/Replace/Insert APIs#1034

Open
XananasX7 wants to merge 1 commit into
DaveGamble:masterfrom
XananasX7:ossfuzz/cjson-mutate-fuzzer
Open

fuzzing: add cjson_mutate_fuzzer for Duplicate/Compare/Replace/Insert APIs#1034
XananasX7 wants to merge 1 commit into
DaveGamble:masterfrom
XananasX7:ossfuzz/cjson-mutate-fuzzer

Conversation

@XananasX7

Copy link
Copy Markdown

Summary

The existing cjson_read_fuzzer covers cJSON_ParseWithOpts, cJSON_Print, cJSON_PrintBuffered, and cJSON_Minify. The following APIs have no OSS-Fuzz coverage:

API Description
cJSON_Duplicate(item, recurse) Deep/shallow recursive copy of a JSON tree
cJSON_Compare(a, b, case_sensitive) Deep equality comparison
cJSON_ParseWithLengthOpts Length-bounded parse (no NUL needed)
cJSON_InsertItemInArray Mid-array insertion with item shift
cJSON_DetachItemFromArray Detach item and re-insert
cJSON_ReplaceItemViaPointer In-place item replacement

New harness: fuzzing/cjson_mutate_fuzzer.c

Uses a single fuzz-byte to select which operation sequence to execute:

  • op 0Duplicate(recurse=1)Compare for equality
  • op 1 – Build array, InsertItemInArray at position 0, DetachItemFromArray
  • op 2ReplaceItemViaPointer on root's first child
  • op 3ParseWithLengthOpts with a deliberately short length bound
  • op 4Duplicate(recurse=0) (shallow) → PrintUnformatted
  • op 5Compare root against itself (both case modes)

Compiles cleanly with clang -fsyntax-only.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant