Skip to content
Myr

Fix NUL truncation in the JSON parser

Before adoption: this commit came in with the history the project adopted, so no landing records it.

This fixes CVE-2026-33948.

authored by itchyny · committed by itchyny · parent fdf8ef0 · Browse files · 2 files+7 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+7 added−7 removed

  • tests:+6 added−0 removed
  • other:+1 added−7 removed

2 files+7 added−7 removed

modified:src/util.c+1 added-7 removed
310 unmodified lines
311312 if (p != NULL)313 state->current_line++;314315 if (p == NULL && state->parser != NULL) {316 /*317 * There should be no NULs in JSON texts (but JSON text318 * sequences are another story).319 */320 state->buf_valid_len = strlen(state->buf);321 } else if (p == NULL && feof(state->current_input)) {315 if (p == NULL && feof(state->current_input)) {316 size_t i;317318 /*319 * XXX We don't know how many bytes we've read!
939 unmodified lines
modified:tests/shtest+6 added
878 unmodified lines
879 exit 1880}881diff $d/out $d/expected882883# CVE-2026-33948: No NUL truncation in the JSON parser884if printf '{}\x00{}' | $JQ >/dev/null 2> /dev/null; then885 printf 'Error expected but jq exited successfully\n' 1>&2886 exit 1887fi888889exit 0