Fix NUL truncation in the JSON parser

This fixes CVE-2026-33948.
This commit is contained in:
itchyny committed 2026-04-13 08:46:11 +09:00
1 parent fdf8ef0f08
commit 6374ae0bcd
2 files changed
+7 -7

No files matched your search

+1 -7
View File
@@ -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;
/*
+6
View File
@@ -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