Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding additional alz error checking. #1273

Merged
merged 2 commits into from
Jul 19, 2024
Merged
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
4 changes: 3 additions & 1 deletion libclamav_rust/src/alz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,9 @@ impl AlzLocalFileHeader {
data: buffer.to_vec(),
};

files.push(extracted_file);
if 0 != extracted_file.data.len() {
files.push(extracted_file);
}
}

fn extract_file_nocomp(
Expand Down
11 changes: 8 additions & 3 deletions libclamav_rust/src/scanners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ pub fn magic_scan(ctx: *mut cli_ctx, buf: &[u8], name: Option<String>) -> cl_err
let ptr = buf.as_ptr();
let len = buf.len();

if 0 == len {
return cl_error_t_CL_SUCCESS;
}

match &name {
Some(name) => debug!("Scanning {}-byte file named {}.", len, name),
Some(name) => debug!("Scanning {}-byte file named {:?}.", len, name),
None => debug!("Scanning {}-byte unnamed file.", len),
}

Expand All @@ -70,13 +74,14 @@ pub fn magic_scan(ctx: *mut cli_ctx, buf: &[u8], name: Option<String>) -> cl_err
};

let ret = unsafe { cli_magic_scan_buff(ptr as *const c_void, len, ctx, name_ptr, 0) };

if ret != cl_error_t_CL_SUCCESS {
debug!("cli_magic_scan_buff returned error: {}", ret);
}

// Okay now safe to drop the name CString.
let _ = unsafe { CString::from_raw(name_ptr) };
if !name_ptr.is_null() {
let _ = unsafe { CString::from_raw(name_ptr) };
}

ret
}
Expand Down
Loading