rust/asn1: replace rs_ naming with SC naming

pull/13152/head
Jason Ish 4 months ago committed by Victor Julien
parent 90116827fe
commit 713034d0dd

@ -215,9 +215,9 @@ fn asn1_decode<'a>(
/// # Safety
///
/// input must be a valid buffer of at least input_len bytes
/// pointer must be freed using `rs_asn1_free`
/// pointer must be freed using `SCAsn1Free`
#[no_mangle]
pub unsafe extern "C" fn rs_asn1_decode(
pub unsafe extern "C" fn SCAsn1Decode(
input: *const u8, input_len: u32, buffer_offset: u32, ad_ptr: *const DetectAsn1Data,
) -> *mut Asn1<'static> {
if input.is_null() || input_len == 0 || ad_ptr.is_null() {
@ -240,9 +240,9 @@ pub unsafe extern "C" fn rs_asn1_decode(
///
/// # Safety
///
/// ptr must be a valid object obtained using `rs_asn1_decode`
/// ptr must be a valid object obtained using `SCAsn1Decode`
#[no_mangle]
pub unsafe extern "C" fn rs_asn1_free(ptr: *mut Asn1) {
pub unsafe extern "C" fn SCAsn1Free(ptr: *mut Asn1) {
if ptr.is_null() {
return;
}
@ -256,12 +256,12 @@ pub unsafe extern "C" fn rs_asn1_free(ptr: *mut Asn1) {
///
/// # Safety
///
/// ptr must be a valid object obtained using `rs_asn1_decode`
/// ad_ptr must be a valid object obtained using `rs_detect_asn1_parse`
/// ptr must be a valid object obtained using `SCAsn1Decode`
/// ad_ptr must be a valid object obtained using `SCAsn1DetectParse`
///
/// Returns 1 if any of the options match, 0 if not
#[no_mangle]
pub unsafe extern "C" fn rs_asn1_checks(ptr: *const Asn1, ad_ptr: *const DetectAsn1Data) -> u8 {
pub unsafe extern "C" fn SCAsn1Checks(ptr: *const Asn1, ad_ptr: *const DetectAsn1Data) -> u8 {
if ptr.is_null() || ad_ptr.is_null() {
return 0;
}

@ -32,9 +32,9 @@ const ASN1_DEFAULT_MAX_FRAMES: u16 = 30;
///
/// # Safety
///
/// pointer must be free'd using `rs_detect_asn1_free`
/// pointer must be free'd using `SCAsn1DetectFree`
#[no_mangle]
pub unsafe extern "C" fn rs_detect_asn1_parse(input: *const c_char) -> *mut DetectAsn1Data {
pub unsafe extern "C" fn SCAsn1DetectParse(input: *const c_char) -> *mut DetectAsn1Data {
if input.is_null() {
return std::ptr::null_mut();
}
@ -73,9 +73,9 @@ pub unsafe extern "C" fn rs_detect_asn1_parse(input: *const c_char) -> *mut Dete
///
/// # Safety
///
/// ptr must be a valid object obtained using `rs_detect_asn1_parse`
/// ptr must be a valid object obtained using `SCAsn1DetectParse`
#[no_mangle]
pub unsafe extern "C" fn rs_detect_asn1_free(ptr: *mut DetectAsn1Data) {
pub unsafe extern "C" fn SCAsn1DetectFree(ptr: *mut DetectAsn1Data) {
if ptr.is_null() {
return;
}

@ -59,9 +59,9 @@ bool DetectAsn1Match(const SigMatchData *smd, const uint8_t *buffer, const uint3
const uint32_t offset)
{
const DetectAsn1Data *ad = (const DetectAsn1Data *)smd->ctx;
Asn1 *asn1 = rs_asn1_decode(buffer, buffer_len, offset, ad);
uint8_t ret = rs_asn1_checks(asn1, ad);
rs_asn1_free(asn1);
Asn1 *asn1 = SCAsn1Decode(buffer, buffer_len, offset, ad);
uint8_t ret = SCAsn1Checks(asn1, ad);
SCAsn1Free(asn1);
return ret == 1;
}
@ -75,7 +75,7 @@ bool DetectAsn1Match(const SigMatchData *smd, const uint8_t *buffer, const uint3
*/
static DetectAsn1Data *DetectAsn1Parse(const char *asn1str)
{
DetectAsn1Data *ad = rs_detect_asn1_parse(asn1str);
DetectAsn1Data *ad = SCAsn1DetectParse(asn1str);
if (ad == NULL) {
SCLogError("Malformed asn1 argument: %s", asn1str);
@ -120,7 +120,7 @@ static int DetectAsn1Setup(DetectEngineCtx *de_ctx, Signature *s, const char *as
static void DetectAsn1Free(DetectEngineCtx *de_ctx, void *ptr)
{
DetectAsn1Data *ad = (DetectAsn1Data *)ptr;
rs_detect_asn1_free(ad);
SCAsn1DetectFree(ad);
}
#ifdef UNITTESTS

Loading…
Cancel
Save