]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
rust/asn1: replace rs_ naming with SC naming
authorJason Ish <jason.ish@oisf.net>
Fri, 2 May 2025 17:21:57 +0000 (11:21 -0600)
committerVictor Julien <victor@inliniac.net>
Sat, 3 May 2025 06:19:41 +0000 (08:19 +0200)
rust/src/asn1/mod.rs
rust/src/asn1/parse_rules.rs
src/detect-asn1.c

index e458342742e9ad6964e155c814ac30b034dd461d..40cd7a76aa6ee2538314eafc6004372aeb64e28a 100644 (file)
@@ -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;
     }
index 9a857868db9836c419e0cbca9899054c12fcdcae..9bb0b2558eb5ec58b4f7f543c5f961b1c0434b29 100644 (file)
@@ -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;
     }
index c70bf8921fd3204b50e803f9bc4f077b8ea1d8dc..63d40d6219fcad89e9c38440bbfaa12763a34f70 100644 (file)
@@ -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