Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ pub struct Engine {
unsafe impl Send for Engine {}
unsafe impl Sync for Engine {}

fn map_scan_result(result: cl_error_t, virname: *const i8) -> Result<ScanResult, ClamError> {
fn map_scan_result(result: cl_error_t, virname: *const libc::c_char) -> Result<ScanResult, ClamError> {
match result {
cl_error_t::CL_CLEAN => Ok(ScanResult::Clean),
cl_error_t::CL_BREAK => Ok(ScanResult::Whitelisted),
Expand Down Expand Up @@ -231,7 +231,7 @@ impl Engine {
pub fn scan_file(&self, path: &str, settings: &mut ScanSettings) -> Result<ScanResult, ClamError> {
let raw_path = CString::new(path).unwrap();
unsafe {
let mut virname: *const i8 = ptr::null();
let mut virname: *const libc::c_char = ptr::null();
let result = clamav_sys::cl_scanfile(
raw_path.as_ptr(),
&mut virname,
Expand All @@ -249,7 +249,7 @@ impl Engine {
/// loaded and compiled.
pub fn scan_descriptor(&self, descriptor: i32, settings: &mut ScanSettings, filename: Option< &str >) -> Result<ScanResult, ClamError> {
unsafe {
let mut virname: *const i8 = ptr::null();
let mut virname: *const libc::c_char = ptr::null();
let filename_cstr = filename.map(|x| CString::new(x).expect("CString::new failed"));
let mut scanned : c_ulong = 0;
let result = clamav_sys::cl_scandesc(
Expand Down Expand Up @@ -283,7 +283,7 @@ impl Engine {
/// @param engine The scanning engine.
/// @param scanoptions The scanning options.
pub fn scan_map(&self, map : & Fmap, filename: Option<&str>, settings: &mut ScanSettings) -> Result<ScanResult, ClamError> {
let mut virname: *const i8 = ptr::null();
let mut virname: *const libc::c_char = ptr::null();
let c_filename = filename.map(|n| CString::new(n).expect("CString::new failed"));
let result = unsafe {
clamav_sys::cl_scanmap_callback(
Expand Down Expand Up @@ -582,9 +582,9 @@ mod tests {
.load_databases(EXAMPLE_DATABASE_PATH)
.expect("failed to load db");
scanner.compile().expect("failed to compile");
let settings: ScanSettings = Default::default();
let mut settings: ScanSettings = Default::default();
let file = File::open(NAUGHTY_FILE_PATH).unwrap();
let result = scanner.scan_fileobj(&file, &settings);
let result = scanner.scan_fileobj(&file, &mut settings, Some(NAUGHTY_FILE_PATH));
assert!(result.is_ok(), "scan should succeed");
let hit = result.unwrap();
match hit {
Expand Down
1 change: 0 additions & 1 deletion src/scan_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@ mod tests {
assert!(string_settings.contains("CL_SCAN_PARSE_ELF"));
assert!(string_settings.contains("CL_SCAN_PARSE_SWF"));
assert!(string_settings.contains("CL_SCAN_PARSE_XMLDOCS"));
assert!(string_settings.contains("CL_SCAN_Parse_HWP3"));
}

#[test]
Expand Down