diff --git a/Cargo.lock b/Cargo.lock index 5d536d109f..a277925517 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -25,9 +25,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.21.4" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bindgen" @@ -66,9 +66,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bitflags" -version = "2.4.0" +version = "2.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4682ae6287fcf752ecaabbfcc7b6f9b72aa33933dc23a554d853aea8eea8635" +checksum = "327762f6e5a765692301e5bb513e0d9fef63be86bbc14528052b1cd3e6f03e07" [[package]] name = "block-buffer" @@ -139,6 +139,7 @@ dependencies = [ "cbindgen", "flate2", "hex", + "hex-literal", "image", "libc", "log", @@ -172,9 +173,9 @@ checksum = "3d7b894f5411737b7867f4827955924d7c254fc9f4d91a6aad6b097804b1018b" [[package]] name = "cpufeatures" -version = "0.2.9" +version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a17b76ff3a4162b0b27f354a0c87015ddad39d35f9c0c36607a3bdd175dde1f1" +checksum = "ce420fe07aecd3e67c5f910618fe65e94158f6dcc0adf44e00d69ce2bdfe0fd0" dependencies = [ "libc", ] @@ -307,18 +308,18 @@ checksum = "25cbce373ec4653f1a01a31e8a5e5ec0c622dc27ff9c4e6606eefef5cbbed4a5" [[package]] name = "fdeflate" -version = "0.3.0" +version = "0.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d329bdeac514ee06249dabc27877490f17f5d371ec693360768b838e19f3ae10" +checksum = "64d6dafc854908ff5da46ff3f8f473c6984119a2876a383a860246dd7841a868" dependencies = [ "simd-adler32", ] [[package]] name = "flate2" -version = "1.0.27" +version = "1.0.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c98ee8095e9d1dcbf2fcc6d95acccb90d1c81db1e44725c6a984b1dbdfb010" +checksum = "46303f565772937ffe1d394a4fac6f411c6013172fadde9dcdb1e147a086940e" dependencies = [ "crc32fast", "miniz_oxide", @@ -386,6 +387,12 @@ version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70" +[[package]] +name = "hex-literal" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fe2267d4ed49bc07b63801559be28c718ea06c4738b7a03c94df7386d2cde46" + [[package]] name = "home" version = "0.5.5" @@ -490,9 +497,9 @@ checksum = "da2479e8c062e40bf0066ffa0bc823de0a9368974af99c9f6df941d2c231e03f" [[package]] name = "lock_api" -version = "0.4.10" +version = "0.4.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1cc9717a20b1bb222f333e6a92fd32f7d8a18ddc5a3191a11af45dcbf4dcd16" +checksum = "3c168f8615b12bc01f9c17e2eb0cc07dcae1940121185446edc3744920e8ef45" dependencies = [ "autocfg", "scopeguard", @@ -593,7 +600,7 @@ checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" [[package]] name = "onenote_parser" version = "0.3.1" -source = "git+https://github.com/micahsnyder/onenote.rs.git?branch=CLAM-2329-new-from-slice#c155f31fc1db0361e8bacf0656a1272e81a52c20" +source = "git+https://github.com/micahsnyder/onenote.rs.git?branch=CLAM-2329-new-from-slice#8b450447e58143004b68dd21c11b710fdb79be92" dependencies = [ "bytes", "encoding_rs", @@ -699,18 +706,18 @@ dependencies = [ [[package]] name = "redox_syscall" -version = "0.3.5" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +checksum = "4722d768eff46b75989dd134e5c353f0d6296e5aaa3132e776cbdb56be7731aa" dependencies = [ "bitflags 1.3.2", ] [[package]] name = "regex" -version = "1.10.0" +version = "1.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d119d7c7ca818f8a53c300863d4f87566aac09943aef5b355bb83969dae75d87" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" dependencies = [ "aho-corasick", "memchr", @@ -720,9 +727,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.1" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "465c6fc0621e4abc4187a2bda0937bfd4f722c2730b29562e19689ea796c9a4b" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ "aho-corasick", "memchr", @@ -731,9 +738,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.0" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3cbb081b9784b07cceb8824c8583f86db4814d172ab043f3c23f7dc600bf83d" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustc-hash" @@ -767,11 +774,11 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.18" +version = "0.38.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a74ee2d7c2581cd139b42447d7d9389b889bdaad3a73f1ebb16f2a3237bb19c" +checksum = "2b426b0506e5d50a7d8dafcf2e81471400deb602392c7dd110815afb4eaf02a3" dependencies = [ - "bitflags 2.4.0", + "bitflags 2.4.1", "errno", "libc", "linux-raw-sys", @@ -792,18 +799,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" [[package]] name = "serde" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e" +checksum = "91d3c334ca1ee894a2c6f6ad698fe8c435b76d504b13d436f0685d648d6d96f7" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.188" +version = "1.0.190" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2" +checksum = "67c5609f394e5c2bd7fc51efda478004ea80ef42fee983d5c67a65e34f32c0e3" dependencies = [ "proc-macro2", "quote", @@ -812,9 +819,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.108" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "3d1c7e3eac408d115102c4c24ad393e0821bb3a5df4d506a80f85f7a742a526b" dependencies = [ "itoa", "ryu", @@ -900,9 +907,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.8.0" +version = "3.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb94d2f3cc536af71caac6b6fcebf65860b347e7ce0cc9ebe8f70d3e521054ef" +checksum = "7ef1adac450ad7f4b3c28589471ade84f25f731a7a0fe30d71dfa9f60fd808e5" dependencies = [ "cfg-if", "fastrand", @@ -913,18 +920,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1177e8c6d7ede7afde3585fd2513e611227efd6481bd78d2e82ba1ce16557ed4" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.49" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "10712f02019e9288794769fba95cd6847df9874d49d871d062172f9dd41bc4cc" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", @@ -981,9 +988,9 @@ checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" [[package]] name = "uuid" -version = "1.4.1" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d" +checksum = "88ad59a7560b41a70d191093a945f0b87bc1deeda46fb237479708a1d6b6cdfc" [[package]] name = "version_check" diff --git a/libclamav_rust/Cargo.toml b/libclamav_rust/Cargo.toml index 1937fda1ec..c7e3fba998 100644 --- a/libclamav_rust/Cargo.toml +++ b/libclamav_rust/Cargo.toml @@ -21,6 +21,7 @@ sha1 = "0.10.5" unicode-segmentation = "1.10.1" bindgen = "0.65" onenote_parser = { git = "https://github.com/micahsnyder/onenote.rs.git", branch = "CLAM-2329-new-from-slice" } +hex-literal = "0.4.1" [lib] crate-type = ["staticlib"] diff --git a/libclamav_rust/build.rs b/libclamav_rust/build.rs index 7a43801f0f..56d2714b64 100644 --- a/libclamav_rust/build.rs +++ b/libclamav_rust/build.rs @@ -139,7 +139,7 @@ fn execute_bindgen() -> Result<(), &'static str> { // Silence code-style warnings for generated bindings. .raw_line("#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals)]") // Make the bindings pretty. - .rustfmt_bindings(true) + .formatter(bindgen::Formatter::Rustfmt) // Disable the layout tests. // We're commiting to source control. Pointer width, integer size, etc // are probably not the same when generated as when compiled. diff --git a/libclamav_rust/src/ctx.rs b/libclamav_rust/src/ctx.rs index 4885d5f8d6..4dfff66e4e 100644 --- a/libclamav_rust/src/ctx.rs +++ b/libclamav_rust/src/ctx.rs @@ -23,15 +23,15 @@ use std::convert::TryInto; use std::slice; -use thiserror::Error; +use thiserror; use crate::fmap::FMap; use crate::sys::cli_ctx; use crate::util::optional_cstring; -/// OneDumpError enumerates all possible errors returned by this library. -#[derive(Error, Debug)] -pub enum CtxError { +/// Error enumerates all possible errors returned by this library. +#[derive(thiserror::Error, Debug)] +pub enum Error { #[error("Invalid format")] Format, @@ -53,9 +53,9 @@ pub enum CtxError { /// # Safety /// /// Must be a valid ctx pointer. -pub fn sub_filepath(ctx: *mut cli_ctx) -> Result, CtxError> { +pub fn sub_filepath(ctx: *mut cli_ctx) -> Result, Error> { if ctx.is_null() { - return Err(CtxError::NullPointer("ctx")); + return Err(Error::NullPointer("ctx")); } Ok(optional_cstring(unsafe { *ctx }.sub_filepath)) @@ -66,9 +66,9 @@ pub fn sub_filepath(ctx: *mut cli_ctx) -> Result, CtxError> /// # Safety /// /// Must be a valid ctx pointer. -pub fn target_filepath(ctx: *mut cli_ctx) -> Result, CtxError> { +pub fn target_filepath(ctx: *mut cli_ctx) -> Result, Error> { if ctx.is_null() { - return Err(CtxError::NullPointer("ctx")); + return Err(Error::NullPointer("ctx")); } Ok(optional_cstring(unsafe { *ctx }.target_filepath)) @@ -79,9 +79,9 @@ pub fn target_filepath(ctx: *mut cli_ctx) -> Result, CtxErr /// # Safety /// /// Must be a valid ctx pointer. -pub fn current_fmap(ctx: *mut cli_ctx) -> Result { +pub fn current_fmap(ctx: *mut cli_ctx) -> Result { if ctx.is_null() { - return Err(CtxError::NullPointer("ctx")); + return Err(Error::NullPointer("ctx")); } let recursion_stack_size = unsafe { *ctx }.recursion_stack_size as usize; @@ -92,5 +92,5 @@ pub fn current_fmap(ctx: *mut cli_ctx) -> Result { let current_level = recursion_stack[recursion_level]; - current_level.fmap.try_into().map_err(|_| CtxError::BadMap) + current_level.fmap.try_into().map_err(|_| Error::BadMap) } diff --git a/libclamav_rust/src/onenote.rs b/libclamav_rust/src/onenote.rs index d770a1cd50..01d49a130b 100644 --- a/libclamav_rust/src/onenote.rs +++ b/libclamav_rust/src/onenote.rs @@ -22,16 +22,18 @@ use std::mem; use std::panic; +use std::path::Path; use std::path::PathBuf; use log::{debug, error}; -use thiserror::Error; +use thiserror; +use hex_literal::hex; use onenote_parser; -/// OneDumpError enumerates all possible errors returned by this library. -#[derive(Error, Debug)] -pub enum OneDumpError { +/// Error enumerates all possible errors returned by this library. +#[derive(thiserror::Error, Debug)] +pub enum Error { #[error("Invalid format")] Format, @@ -63,13 +65,18 @@ fn find_bytes(haystack: &[u8], needle: &[u8]) -> Option { .position(|window| window == needle) } +/// Struct representing a file extracted from a OneNote document. +/// This has the option of providing a file name, if one was found when extracting the file. pub struct ExtractedFile { pub name: Option, pub data: Vec, } +/// Struct used for a file handle for our OneNote parser. +/// This struct is used to keep track of state for our iterator to work through the document extracting each file. +/// There are three different ways we keep track of state depending on the file format and the way in which the file was opened. #[derive(Default)] -pub struct OneDump<'a> { +pub struct OneNote<'a> { embedded_files: Vec, remaining_vec: Option>, remaining: Option<&'a [u8]>, @@ -77,28 +84,34 @@ pub struct OneDump<'a> { // https://learn.microsoft.com/en-us/openspecs/office_file_formats/ms-onestore/8806fd18-6735-4874-b111-227b83eaac26 #[repr(packed)] +#[allow(dead_code)] struct FileDataHeader { - _guid_header: [u8; 16], - _cb_length: u64, - _unused: u32, - _reserved: u64, + guid_header: [u8; 16], + cb_length: u64, + unused: u32, + reserved: u64, } +const SIZE_OF_FILE_DATA_HEADER: usize = mem::size_of::(); -impl<'a> OneDump<'a> { - pub fn from_bytes(data: &'a [u8], filename: &str) -> Result, OneDumpError> { +// Hex sequence identifying the start of a file data store object. +const FILE_DATA_STORE_OBJECT: &[u8] = &hex!("e716e3bd65261145a4c48d4d0b7a9eac"); + +// Hex sequence identifying the start of a OneNote file. +const ONE_MAGIC: &[u8] = &hex!("e4525c7b8cd8a74daeb15378d02996d3"); + +impl<'a> OneNote<'a> { + /// Open a OneNote document given a slice bytes. + pub fn from_bytes(data: &'a [u8], filename: &Path) -> Result, Error> { debug!( "Inspecting OneNote file for attachments from in-memory buffer of size {}-bytes named {}\n", - data.len(), filename + data.len(), filename.to_string_lossy() ); - fn parse_section_buffer( - data: &[u8], - filename: &str, - ) -> Result, OneDumpError> { + fn parse_section_buffer(data: &[u8], filename: &Path) -> Result, Error> { let mut embedded_files: Vec = vec![]; let mut parser = onenote_parser::Parser::new(); - if let Ok(section) = parser.parse_section_buffer(data, &filename) { + if let Ok(section) = parser.parse_section_buffer(data, filename) { // file appears to be OneStore 2.8 `.one` file. section.page_series().iter().for_each(|page_series| { page_series.pages().iter().for_each(|page| { @@ -136,7 +149,7 @@ impl<'a> OneDump<'a> { }); }); } else { - return Err(OneDumpError::Parse); + return Err(Error::Parse); } Ok(embedded_files) @@ -144,90 +157,44 @@ impl<'a> OneDump<'a> { // Try to parse the section buffer using the onenote_parser crate. // Attempt to catch panics in case the parser encounter unexpected issues. - let result_result = panic::catch_unwind(|| -> Result, OneDumpError> { - let embedded_files = parse_section_buffer(data, filename)?; - Ok(embedded_files) + let result_result = panic::catch_unwind(|| -> Result, Error> { + Ok(parse_section_buffer(data, filename)?) }); // Check if it panicked. If no panic, grab the parse result. - let result = match result_result { - Ok(result) => result, - Err(_) => return Err(OneDumpError::Parse), - }; + let result = result_result.map_err(|_| Error::Parse)?; if let Ok(embedded_files) = result { // Successfully parsed the OneNote file with the onenote_parser crate. - Ok(OneDump { - embedded_files: embedded_files, - remaining_vec: None, - remaining: None, + Ok(OneNote { + embedded_files, + ..Default::default() }) } else { debug!("Unable to parse OneNote file with onenote_parser crate. Trying a different method known to work with older office 2010 OneNote files to extract attachments."); let embedded_files: Vec = vec![]; - const ONE_MAGIC: &[u8] = &[ - 0xe4, 0x52, 0x5c, 0x7b, 0x8c, 0xd8, 0xa7, 0x4d, 0xae, 0xb1, 0x53, 0x78, 0xd0, 0x29, - 0x96, 0xd3, - ]; - - let file_magic = data.get(0..16); - let file_magic = file_magic.ok_or(OneDumpError::Format)?; - + let file_magic = data.get(0..16).ok_or(Error::Format)?; if file_magic != ONE_MAGIC { - return Err(OneDumpError::Format); + return Err(Error::Format); } - Ok(OneDump { - embedded_files: embedded_files, - remaining_vec: None, + Ok(OneNote { + embedded_files, remaining: Some(data), + ..Default::default() }) } } - pub fn find_next_file(&'a mut self, remaining_in: &'a [u8]) -> Option<&'a [u8]> { - debug!("Looking for next file in OneNote section..."); - - let file_data_store_object: &[u8] = &[ - 0xE7, 0x16, 0xE3, 0xBD, 0x65, 0x26, 0x11, 0x45, 0xA4, 0xC4, 0x8D, 0x4D, 0x0B, 0x7A, - 0x9E, 0xAC, - ]; - - let remaining = if let Some(pos) = find_bytes(remaining_in, file_data_store_object) { - let (_, remaining) = remaining_in.split_at(pos + "url".len()); - // Found file data store object. - remaining - } else { - // No occurence of "url" - // No more 'url's. - return None; - }; - - let data_length_bytes = &remaining[16..4]; - let data_length = ((data_length_bytes[1] as u64) << 24) - | ((data_length_bytes[2] as u64) << 16) - | ((data_length_bytes[3] as u64) << 8) - | (data_length_bytes[4] as u64); - - let file_data: &[u8] = &remaining[mem::size_of::()..=data_length as usize]; - - Some(file_data) - } - pub fn next_file(&mut self) -> Option { debug!("Looking to extract file from OneNote section..."); let mut file_data: Option> = None; let remaining = if let Some(remaining_in) = self.remaining { - let file_data_store_object: &[u8] = &[ - 0xE7, 0x16, 0xE3, 0xBD, 0x65, 0x26, 0x11, 0x45, 0xA4, 0xC4, 0x8D, 0x4D, 0x0B, 0x7A, - 0x9E, 0xAC, - ]; - - let remaining = if let Some(pos) = find_bytes(remaining_in, file_data_store_object) { + let remaining = if let Some(pos) = find_bytes(remaining_in, FILE_DATA_STORE_OBJECT) { let (_, remaining) = remaining_in.split_at(pos); // Found file data store object. remaining @@ -241,14 +208,14 @@ impl<'a> OneDump<'a> { | ((data_length_bytes[1] as u64) << 8) | (data_length_bytes[0] as u64); - let data: &[u8] = &remaining[mem::size_of::() - ..mem::size_of::() + data_length as usize]; + let data: &[u8] = &remaining[SIZE_OF_FILE_DATA_HEADER + ..SIZE_OF_FILE_DATA_HEADER + data_length as usize]; file_data = Some(data.to_vec()); Some( &remaining - [mem::size_of::() + (data_length as usize)..remaining.len()], + [SIZE_OF_FILE_DATA_HEADER + (data_length as usize)..remaining.len()], ) } else { None @@ -272,12 +239,7 @@ impl<'a> OneDump<'a> { let mut file_data: Option> = None; self.remaining_vec = if let Some(ref remaining_vec) = self.remaining_vec { - let file_data_store_object: &[u8] = &[ - 0xE7, 0x16, 0xE3, 0xBD, 0x65, 0x26, 0x11, 0x45, 0xA4, 0xC4, 0x8D, 0x4D, 0x0B, 0x7A, - 0x9E, 0xAC, - ]; - - let remaining = if let Some(pos) = find_bytes(remaining_vec, file_data_store_object) { + let remaining = if let Some(pos) = find_bytes(remaining_vec, FILE_DATA_STORE_OBJECT) { let (_, remaining) = remaining_vec.split_at(pos); // Found file data store object. remaining @@ -291,14 +253,14 @@ impl<'a> OneDump<'a> { | ((data_length_bytes[1] as u64) << 8) | (data_length_bytes[0] as u64); - let data: &[u8] = &remaining[mem::size_of::() - ..mem::size_of::() + data_length as usize]; + let data: &[u8] = &remaining[SIZE_OF_FILE_DATA_HEADER + ..SIZE_OF_FILE_DATA_HEADER + data_length as usize]; file_data = Some(data.to_vec()); Some(Vec::from( &remaining - [mem::size_of::() + (data_length as usize)..remaining.len()], + [SIZE_OF_FILE_DATA_HEADER + (data_length as usize)..remaining.len()], )) } else { None @@ -319,35 +281,20 @@ impl<'a> OneDump<'a> { } } -impl<'a> Iterator for OneDump<'a> { +impl<'a> Iterator for OneNote<'a> { type Item = ExtractedFile; fn next(&mut self) -> Option { // Find the next embedded file if self.remaining.is_some() { // Data stored in a slice. - if let Some(file) = self.next_file() { - // Decode the base64 encoded image - Some(file) - } else { - None - } + self.next_file() } else if self.remaining_vec.is_some() { // Data stored in a Vec. - if let Some(file) = self.next_file_vec() { - // Decode the base64 encoded image - Some(file) - } else { - None - } + self.next_file_vec() } else if self.embedded_files.len() > 0 { // Data stored in a Vec. - if let Some(file) = self.next_file_parser() { - // Decode the base64 encoded image - Some(file) - } else { - None - } + self.next_file_parser() } else { None } diff --git a/libclamav_rust/src/scanners.rs b/libclamav_rust/src/scanners.rs index 690e4bd4a7..ab88ff2a2e 100644 --- a/libclamav_rust/src/scanners.rs +++ b/libclamav_rust/src/scanners.rs @@ -21,13 +21,14 @@ */ use std::ffi::{c_char, CString}; +use std::path::Path; use std::ptr::null_mut; use libc::c_void; use log::{debug, error, warn}; use crate::ctx; -use crate::onenote::OneDump; +use crate::onenote::OneNote; use crate::sys::{ cl_error_t, cl_error_t_CL_ERROR, cl_error_t_CL_SUCCESS, cli_ctx, cli_magic_scan_buff, }; @@ -93,7 +94,7 @@ pub unsafe extern "C" fn scan_onenote(ctx: *mut cli_ctx) -> cl_error_t { } }; - let one = OneDump::from_bytes(file_bytes, fmap.name()); + let one = OneNote::from_bytes(file_bytes, &Path::new(fmap.name())); let one = match one { Ok(x) => x,