2
1
mirror of https://github.com/qpdf/qpdf.git synced 2024-11-16 17:45:09 +00:00

Validate key length in Pl_AES_PDF constructor

This commit is contained in:
m-holger 2024-11-08 12:44:36 +00:00
parent 54cf0e519c
commit 64e9839710
4 changed files with 5 additions and 1 deletions

View File

@ -149,6 +149,7 @@ set(CORPUS_OTHER
99999e.fuzz 99999e.fuzz
369662293.fuzz 369662293.fuzz
369662293a.fuzz 369662293a.fuzz
377977949.fuzz
) )
set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus) set(CORPUS_DIR ${CMAKE_CURRENT_BINARY_DIR}/qpdf_corpus)

Binary file not shown.

View File

@ -11,7 +11,7 @@ my $td = new TestDriver('fuzz');
my $qpdf_corpus = $ENV{'QPDF_FUZZ_CORPUS'} || die "must set QPDF_FUZZ_CORPUS"; 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 = ( my @fuzzers = (
['ascii85' => 1], ['ascii85' => 1],

View File

@ -23,6 +23,9 @@ Pl_AES_PDF::Pl_AES_PDF(
if (!next) { if (!next) {
throw std::logic_error("Attempt to create Pl_AES_PDF with nullptr as 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); this->key = std::make_unique<unsigned char[]>(key_bytes);
std::memcpy(this->key.get(), key, key_bytes); std::memcpy(this->key.get(), key, key_bytes);
std::memset(this->inbuf, 0, this->buf_size); std::memset(this->inbuf, 0, this->buf_size);