Skip to content

Commit

Permalink
rust/transforms/hash: don't no_mangle non-pub functions
Browse files Browse the repository at this point in the history
By adding no_mangle to non-pub functions they enter the global name
space and can conflict with other functions. In this case another sha
library used by a plugin.
  • Loading branch information
jasonish committed Jan 16, 2025
1 parent a9ba451 commit ad50851
Showing 1 changed file with 0 additions and 6 deletions.
6 changes: 0 additions & 6 deletions rust/src/detect/transforms/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ static mut G_TRANSFORM_SHA256_ID: c_int = 0;

const SC_MD5_LEN: usize = 16;

#[no_mangle]
unsafe extern "C" fn md5_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -50,7 +49,6 @@ fn md5_transform_do(input: &[u8], output: &mut [u8]) {
Md5::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn md5_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -91,7 +89,6 @@ pub unsafe extern "C" fn DetectTransformMd5Register() {
}
}

#[no_mangle]
unsafe extern "C" fn sha1_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -106,7 +103,6 @@ fn sha1_transform_do(input: &[u8], output: &mut [u8]) {
Sha1::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn sha1_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down Expand Up @@ -147,7 +143,6 @@ pub unsafe extern "C" fn DetectTransformSha1Register() {
}
}

#[no_mangle]
unsafe extern "C" fn sha256_setup(
_de: *mut c_void, s: *mut c_void, _raw: *const std::os::raw::c_char,
) -> c_int {
Expand All @@ -162,7 +157,6 @@ fn sha256_transform_do(input: &[u8], output: &mut [u8]) {
Sha256::new().chain(input).finalize_into(output.into());
}

#[no_mangle]
unsafe extern "C" fn sha256_transform(buffer: *mut c_void, _ctx: *mut c_void) {
let input = InspectionBufferPtr(buffer);
let input_len = InspectionBufferLength(buffer);
Expand Down

0 comments on commit ad50851

Please sign in to comment.