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

Fix FFI compatibility issue when building on macOS #7

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ homepage = "https://github.com/Cisco-Talos/clamav-async-rs"
license = "GPL-2.0"
name = "clamav-async"
repository = "https://github.com/Cisco-Talos/clamav-async-rs"
version = "0.2.0"
version = "0.2.1"
keywords = ["antivirus", "async", "clamav"]

[features]
Expand Down
7 changes: 5 additions & 2 deletions src/cvd/head_libclamav.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
// MA 02110-1301, USA.

use super::{HeadError, Meta};
use std::{borrow::Cow, ffi::CStr};
use std::{
borrow::Cow,
ffi::{c_char, CStr},
};

/// The header of a CVD
pub struct Header(*mut clamav_sys::cl_cvd);
Expand All @@ -25,7 +28,7 @@ impl Meta for Header {
/// (or CLD) file
fn from_header_bytes(bytes: &[u8; 512]) -> Result<Self, HeadError> {
unsafe {
let raw = clamav_sys::cl_cvdparse(bytes.as_ptr() as *const i8);
let raw = clamav_sys::cl_cvdparse(bytes.as_ptr() as *const c_char);

if raw.is_null() {
Err(HeadError::Parse)
Expand Down
7 changes: 5 additions & 2 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use clamav_sys::cl_engine_field;
use clamav_sys::{cl_error_t, time_t};
use core::num;
use derivative::Derivative;
use std::ffi::NulError;
use std::ffi::{c_char, NulError};
use std::{path::Path, pin::Pin, sync::Arc, time};

#[cfg(windows)]
Expand All @@ -45,7 +45,10 @@ pub enum ScanResult {
}

impl ScanResult {
pub(crate) fn from_ffi(scan_result: cl_error_t, c_virname: *const i8) -> Result<Self, Error> {
pub(crate) fn from_ffi(
scan_result: cl_error_t,
c_virname: *const c_char,
) -> Result<Self, Error> {
use std::ffi::CStr;

match scan_result {
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub use engine::Error as EngineError;
pub use error::Error as ClamError;
use lazy_static::lazy_static;
use std::{
ffi::CStr,
ffi::{c_char, CStr},
pin::Pin,
sync::{Arc, Mutex, Once},
};
Expand Down Expand Up @@ -112,8 +112,8 @@ pub fn set_msg_callback(cb: MsgCallback) {
///
unsafe extern "C" fn clcb_msg_wrapper(
severity: clamav_sys::cl_msg,
fullmsg: *const i8,
msg: *const i8,
fullmsg: *const c_char,
msg: *const c_char,
_context: *mut libc::c_void,
) {
// Remap the log level to "standard" Rust log levels
Expand Down