Skip to content

Commit

Permalink
Added check for empty data
Browse files Browse the repository at this point in the history
  • Loading branch information
ragusaa authored and micahsnyder committed Jul 8, 2024
1 parent 87e4a34 commit 16fadc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
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
6 changes: 3 additions & 3 deletions libclamav_rust/src/scanners.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ 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 ;
if 0 == len {
return cl_error_t_CL_SUCCESS;
}

match &name {
Expand Down Expand Up @@ -79,7 +79,7 @@ pub fn magic_scan(ctx: *mut cli_ctx, buf: &[u8], name: Option<String>) -> cl_err
}

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

Expand Down

0 comments on commit 16fadc2

Please sign in to comment.