From 0aa6b67eea993fa75c8bb3c6548ec975f8383154 Mon Sep 17 00:00:00 2001 From: m-holger Date: Tue, 24 Sep 2024 01:32:32 +0100 Subject: [PATCH] In QPDFWordTokenFinder::check limit the token length Tokens longer than the target cannot be a match and therefore there is no need to read to the end of token. --- .idea/cmake.xml | 1 - fuzz/CMakeLists.txt | 1 + fuzz/qpdf_extra/99999d.fuzz | Bin 0 -> 5408 bytes fuzz/qtest/fuzz.test | 2 +- libqpdf/QPDFTokenizer.cc | 2 +- 5 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 fuzz/qpdf_extra/99999d.fuzz diff --git a/.idea/cmake.xml b/.idea/cmake.xml index f0a93aba..5762463a 100644 --- a/.idea/cmake.xml +++ b/.idea/cmake.xml @@ -2,7 +2,6 @@ - diff --git a/fuzz/CMakeLists.txt b/fuzz/CMakeLists.txt index adb68cd4..a4af9256 100644 --- a/fuzz/CMakeLists.txt +++ b/fuzz/CMakeLists.txt @@ -145,6 +145,7 @@ set(CORPUS_OTHER 99999a.fuzz 99999b.fuzz 99999c.fuzz + 99999d.fuzz ) set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) diff --git a/fuzz/qpdf_extra/99999d.fuzz b/fuzz/qpdf_extra/99999d.fuzz new file mode 100644 index 0000000000000000000000000000000000000000..4504412f604a5fa072b153bf5f71488eabc137a8 GIT binary patch literal 5408 zcmY#T_^%q^;-+h;XHpDfaH$@D)4zyIRn;@EEI&E1Br`wHN+G?tJTuSCBw0Z>#U-=2 zASbcXEx#x?vBcKU(!$)r0wElfTAZI#3ese2Xkr2sch1i(02-1sKPR)K(kHbnHAfj} zn}Tkkf^L8=P(Ikv%{2%}`}zAjh6cL=Sx$~2&K?T7#V)R4uFkH?1u1FeMVTe3KoS4a zl7i9_x6GVWF?^ za`D`;BjtA*3@3$he0AV<%Q+||b+D;w;$`JBG0v@lXUo~LsjgeKpZ~vc|NqC&wL5>G{~iBsb-=r4|6lL=@!#p@ z)ZP34R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pdf/QPDFTokenizer.cc @@ -47,7 +47,7 @@ QPDFWordTokenFinder::check() // Find a word token matching the given string, preceded by a delimiter, and followed by a // delimiter or EOF. QPDFTokenizer tokenizer; - QPDFTokenizer::Token t = tokenizer.readToken(is, "finder", true); + QPDFTokenizer::Token t = tokenizer.readToken(is, "finder", true, str.size() + 2); qpdf_offset_t pos = is.tell(); if (!(t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, str))) { QTC::TC("qpdf", "QPDFTokenizer finder found wrong word");