diff --git a/src/util.c b/src/util.c index fdfdb96d..80d65fc8 100644 --- a/src/util.c +++ b/src/util.c @@ -312,13 +312,7 @@ static int jq_util_input_read_more(jq_util_input_state *state) { if (p != NULL) state->current_line++; - if (p == NULL && state->parser != NULL) { - /* - * There should be no NULs in JSON texts (but JSON text - * sequences are another story). - */ - state->buf_valid_len = strlen(state->buf); - } else if (p == NULL && feof(state->current_input)) { + if (p == NULL && feof(state->current_input)) { size_t i; /* diff --git a/tests/shtest b/tests/shtest index cb887452..370f7b7c 100755 --- a/tests/shtest +++ b/tests/shtest @@ -880,4 +880,10 @@ $JQ -nf $d/prog.jq 2> $d/out && { } diff $d/out $d/expected +# CVE-2026-33948: No NUL truncation in the JSON parser +if printf '{}\x00{}' | $JQ >/dev/null 2> /dev/null; then + printf 'Error expected but jq exited successfully\n' 1>&2 + exit 1 +fi + exit 0