aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJay Berkenbilt <ejb@ql.org>2024-02-04 23:27:43 +0100
committerJay Berkenbilt <ejb@ql.org>2024-02-04 23:27:49 +0100
commit7ae095fa091af9a94e0e9bf140280a0519859d98 (patch)
treeabccea9e1ed0f4ffa191ec43c9f47754b370a408
parentf0fb19df9d31a550960fac12a6cc96432b885bba (diff)
downloadqpdf-7ae095fa091af9a94e0e9bf140280a0519859d98.tar.zst
Fix JSON parser error found by fuzz
-rw-r--r--fuzz/json_fuzzer_seed_corpus/f297bc5680b3730d3386caa8dee36bf5a853516b1
-rw-r--r--fuzz/qtest/fuzz.test2
-rw-r--r--libqpdf/JSON.cc3
3 files changed, 4 insertions, 2 deletions
diff --git a/fuzz/json_fuzzer_seed_corpus/f297bc5680b3730d3386caa8dee36bf5a853516b b/fuzz/json_fuzzer_seed_corpus/f297bc5680b3730d3386caa8dee36bf5a853516b
new file mode 100644
index 00000000..6c533a40
--- /dev/null
+++ b/fuzz/json_fuzzer_seed_corpus/f297bc5680b3730d3386caa8dee36bf5a853516b
@@ -0,0 +1 @@
+"\,,,,,p,,-\,,,, \ No newline at end of file
diff --git a/fuzz/qtest/fuzz.test b/fuzz/qtest/fuzz.test
index db1efbc1..4a20e5bf 100644
--- a/fuzz/qtest/fuzz.test
+++ b/fuzz/qtest/fuzz.test
@@ -16,7 +16,7 @@ my @fuzzers = (
['dct' => 1],
['flate' => 1],
['hex' => 1],
- ['json' => 37],
+ ['json' => 38],
['lzw' => 2],
['pngpredictor' => 1],
['runlength' => 6],
diff --git a/libqpdf/JSON.cc b/libqpdf/JSON.cc
index c9816809..28f451a9 100644
--- a/libqpdf/JSON.cc
+++ b/libqpdf/JSON.cc
@@ -1246,7 +1246,8 @@ JSONParser::handleToken()
break;
default:
- throw std::logic_error("JSONParser::handleToken : non-terminal lexer state encountered");
+ throw std::runtime_error(
+ "JSON: offset " + std::to_string(offset) + ": premature end of input");
break;
}