Commit 3ea83e9993801b002b4db8abaaa08dec31989ec7
Committed by
GitHub
Merge pull request #1308 from m-holger/fuzz
Validate key length in Pl_AES_PDF constructor
Showing
4 changed files
with
5 additions
and
1 deletions
fuzz/CMakeLists.txt
fuzz/qpdf_extra/377977949.fuzz
0 → 100644
No preview for this file type
fuzz/qtest/fuzz.test
| ... | ... | @@ -11,7 +11,7 @@ my $td = new TestDriver('fuzz'); |
| 11 | 11 | |
| 12 | 12 | my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS"; |
| 13 | 13 | |
| 14 | -my $n_qpdf_files = 86; # increment when adding new files | |
| 14 | +my $n_qpdf_files = 87; # increment when adding new files | |
| 15 | 15 | |
| 16 | 16 | my @fuzzers = ( |
| 17 | 17 | ['ascii85' => 1], | ... | ... |
libqpdf/Pl_AES_PDF.cc
| ... | ... | @@ -23,6 +23,9 @@ Pl_AES_PDF::Pl_AES_PDF( |
| 23 | 23 | if (!next) { |
| 24 | 24 | throw std::logic_error("Attempt to create Pl_AES_PDF with nullptr as next"); |
| 25 | 25 | } |
| 26 | + if (!(key_bytes == 32 || key_bytes == 16)) { | |
| 27 | + throw std::runtime_error("unsupported key length"); | |
| 28 | + } | |
| 26 | 29 | this->key = std::make_unique<unsigned char[]>(key_bytes); |
| 27 | 30 | std::memcpy(this->key.get(), key, key_bytes); |
| 28 | 31 | std::memset(this->inbuf, 0, this->buf_size); | ... | ... |