Skip to content

Commit

Permalink
pe.cert_table: ignore malformed
Browse files Browse the repository at this point in the history
  • Loading branch information
ideeockus committed Jul 30, 2024
1 parent 6177758 commit 2c7f7b5
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions src/pe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,19 @@

// TODO: panics with unwrap on None for apisetschema.dll, fhuxgraphics.dll and some others

use core::cmp::max;

use alloc::borrow::Cow;
use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::max;

use log::debug;
use log::warn;
use scroll::{ctx, Pwrite};

use crate::container;
use crate::error;
use crate::pe::utils::pad;
use crate::strtab;

pub mod authenticode;
pub mod certificate_table;
Expand All @@ -29,15 +36,6 @@ pub mod symbol;
pub mod tls;
pub mod utils;

use crate::container;
use crate::error;
use crate::pe::utils::pad;
use crate::strtab;

use scroll::{ctx, Pwrite};

use log::debug;

#[derive(Debug)]
/// An analyzed PE32/PE32+ binary
pub struct PE<'a> {
Expand Down Expand Up @@ -142,7 +140,7 @@ impl<'a> PE<'a> {
return Err(error::Error::Malformed(format!(
"Unsupported header magic ({:#x})",
magic
)))
)));
}
};

Expand Down Expand Up @@ -268,7 +266,11 @@ impl<'a> PE<'a> {
bytes,
certificate_table.virtual_address,
certificate_table.size,
)?;
)
.unwrap_or_else(|err| {
warn!("Cannot parse CertificateTable: {:?}", err);
Default::default()
});

certificate_table.size as usize
} else {
Expand Down

0 comments on commit 2c7f7b5

Please sign in to comment.