Commit 0aa6b67eea993fa75c8bb3c6548ec975f8383154

Authored by m-holger
1 parent 477fbd98

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
@@ -2,7 +2,6 @@ @@ -2,7 +2,6 @@
2 <project version="4"> 2 <project version="4">
3 <component name="CMakeSharedSettings"> 3 <component name="CMakeSharedSettings">
4 <configurations> 4 <configurations>
5 - <configuration PROFILE_NAME="Debug" ENABLED="true" CONFIG_NAME="Debug" />  
6 <configuration PROFILE_NAME="Maintainer" ENABLED="true" CONFIG_NAME="RelWithDebInfo" GENERATION_OPTIONS="-DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF" /> 5 <configuration PROFILE_NAME="Maintainer" ENABLED="true" CONFIG_NAME="RelWithDebInfo" GENERATION_OPTIONS="-DMAINTAINER_MODE=ON -DBUILD_STATIC_LIBS=OFF" />
7 <configuration PROFILE_NAME="Windows" ENABLED="true" CONFIG_NAME="RelWithDebInfo" TOOLCHAIN_NAME="Visual Studio" GENERATION_OPTIONS="-DBUILD_SHARED_LIBS=OFF" /> 6 <configuration PROFILE_NAME="Windows" ENABLED="true" CONFIG_NAME="RelWithDebInfo" TOOLCHAIN_NAME="Visual Studio" GENERATION_OPTIONS="-DBUILD_SHARED_LIBS=OFF" />
8 </configurations> 7 </configurations>
fuzz/CMakeLists.txt
@@ -145,6 +145,7 @@ set(CORPUS_OTHER @@ -145,6 +145,7 @@ set(CORPUS_OTHER
145 99999a.fuzz 145 99999a.fuzz
146 99999b.fuzz 146 99999b.fuzz
147 99999c.fuzz 147 99999c.fuzz
  148 + 99999d.fuzz
148 ) 149 )
149 150
150 set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) 151 set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus)
fuzz/qpdf_extra/99999d.fuzz 0 → 100644
No preview for this file type
fuzz/qtest/fuzz.test
@@ -11,7 +11,7 @@ my $td = new TestDriver(&#39;fuzz&#39;); @@ -11,7 +11,7 @@ my $td = new TestDriver(&#39;fuzz&#39;);
11 11
12 my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS"; 12 my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS";
13 13
14 -my $n_qpdf_files = 82; # increment when adding new files 14 +my $n_qpdf_files = 83; # increment when adding new files
15 15
16 my @fuzzers = ( 16 my @fuzzers = (
17 ['ascii85' => 1], 17 ['ascii85' => 1],
libqpdf/QPDFTokenizer.cc
@@ -47,7 +47,7 @@ QPDFWordTokenFinder::check() @@ -47,7 +47,7 @@ QPDFWordTokenFinder::check()
47 // Find a word token matching the given string, preceded by a delimiter, and followed by a 47 // Find a word token matching the given string, preceded by a delimiter, and followed by a
48 // delimiter or EOF. 48 // delimiter or EOF.
49 QPDFTokenizer tokenizer; 49 QPDFTokenizer tokenizer;
50 - QPDFTokenizer::Token t = tokenizer.readToken(is, "finder", true); 50 + QPDFTokenizer::Token t = tokenizer.readToken(is, "finder", true, str.size() + 2);
51 qpdf_offset_t pos = is.tell(); 51 qpdf_offset_t pos = is.tell();
52 if (!(t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, str))) { 52 if (!(t == QPDFTokenizer::Token(QPDFTokenizer::tt_word, str))) {
53 QTC::TC("qpdf", "QPDFTokenizer finder found wrong word"); 53 QTC::TC("qpdf", "QPDFTokenizer finder found wrong word");