Skip to content
forked from qpdf/qpdf

Commit

Permalink
Merge pull request qpdf#1308 from m-holger/fuzz
Browse files Browse the repository at this point in the history
Validate key length in Pl_AES_PDF constructor
  • Loading branch information
m-holger authored Nov 8, 2024
2 parents 54cf0e5 + 64e9839 commit 3ea83e9
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions fuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ set(CORPUS_OTHER
99999e.fuzz
369662293.fuzz
369662293a.fuzz
377977949.fuzz
)

set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus)
Expand Down
Binary file added fuzz/qpdf_extra/377977949.fuzz
Binary file not shown.
2 changes: 1 addition & 1 deletion fuzz/qtest/fuzz.test
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ my $td = new TestDriver('fuzz');

my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS";

my $n_qpdf_files = 86; # increment when adding new files
my $n_qpdf_files = 87; # increment when adding new files

my @fuzzers = (
['ascii85' => 1],
Expand Down
3 changes: 3 additions & 0 deletions libqpdf/Pl_AES_PDF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ Pl_AES_PDF::Pl_AES_PDF(
if (!next) {
throw std::logic_error("Attempt to create Pl_AES_PDF with nullptr as next");
}
if (!(key_bytes == 32 || key_bytes == 16)) {
throw std::runtime_error("unsupported key length");
}
this->key = std::make_unique<unsigned char[]>(key_bytes);
std::memcpy(this->key.get(), key, key_bytes);
std::memset(this->inbuf, 0, this->buf_size);
Expand Down

0 comments on commit 3ea83e9

Please sign in to comment.