Skip to content

Commit 1e0f4fc

Browse files
authored
Check for minimum length when reading certs (#61)
1 parent bc9f639 commit 1e0f4fc

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/uthenticode.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -409,15 +409,15 @@ std::vector<WinCert> read_certs(peparse::parsed_pe *pe) {
409409
offset += sizeof(type);
410410

411411
// Continue only we can satisfy the length
412-
if (current_wincert + length <= past_secdir) {
412+
if (current_wincert + length <= past_secdir && length > offset) {
413413
std::vector<std::uint8_t> cert_data(current_wincert + offset, current_wincert + length);
414414

415415
certs.emplace_back(static_cast<certificate_revision>(revision),
416416
static_cast<certificate_type>(type),
417417
cert_data);
418418
}
419419

420-
current_wincert += round(length, 8);
420+
current_wincert += std::max<std::size_t>(round(length, 8), 8);
421421
}
422422

423423
return certs;

0 commit comments

Comments
 (0)