Skip to content

Commit 2642c9f

Browse files
committed
pe.cert_table: ignore malformed
1 parent c9e0000 commit 2642c9f

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/pe/mod.rs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,19 @@
33
44
// TODO: panics with unwrap on None for apisetschema.dll, fhuxgraphics.dll and some others
55

6-
use core::cmp::max;
7-
86
use alloc::borrow::Cow;
97
use alloc::string::String;
108
use alloc::vec::Vec;
9+
use core::cmp::max;
10+
11+
use log::debug;
1112
use log::warn;
13+
use scroll::{ctx, Pwrite};
14+
15+
use crate::container;
16+
use crate::error;
17+
use crate::pe::utils::pad;
18+
use crate::strtab;
1219

1320
pub mod authenticode;
1421
pub mod certificate_table;
@@ -29,15 +36,6 @@ pub mod symbol;
2936
pub mod tls;
3037
pub mod utils;
3138

32-
use crate::container;
33-
use crate::error;
34-
use crate::pe::utils::pad;
35-
use crate::strtab;
36-
37-
use scroll::{ctx, Pwrite};
38-
39-
use log::debug;
40-
4139
#[derive(Debug)]
4240
/// An analyzed PE32/PE32+ binary
4341
pub struct PE<'a> {
@@ -142,7 +140,7 @@ impl<'a> PE<'a> {
142140
return Err(error::Error::Malformed(format!(
143141
"Unsupported header magic ({:#x})",
144142
magic
145-
)))
143+
)));
146144
}
147145
};
148146

@@ -268,7 +266,11 @@ impl<'a> PE<'a> {
268266
bytes,
269267
certificate_table.virtual_address,
270268
certificate_table.size,
271-
)?;
269+
)
270+
.unwrap_or_else(|err| {
271+
warn!("Cannot parse CertificateTable: {:?}", err);
272+
Default::default()
273+
});
272274

273275
certificate_table.size as usize
274276
} else {

0 commit comments

Comments
 (0)