]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect-tls: check return values of functions on setup
authorMats Klepsland <mats.klepsland@gmail.com>
Tue, 14 May 2019 06:12:47 +0000 (08:12 +0200)
committerVictor Julien <victor@inliniac.net>
Sat, 18 May 2019 05:29:23 +0000 (07:29 +0200)
Check the return values of DetectBufferSetActiveList() and
DetectSignatureSetAppProto().

src/detect-tls-cert-fingerprint.c
src/detect-tls-cert-issuer.c
src/detect-tls-cert-serial.c
src/detect-tls-cert-subject.c
src/detect-tls-ja3-hash.c
src/detect-tls-ja3-string.c
src/detect-tls-sni.c

index 7b685de8c2c01dc7ff1d39aaf9afc318df68a79d..7b739f37be409dc5ebee1ffd60f8abaf296c8ed4 100644 (file)
@@ -110,14 +110,16 @@ void DetectTlsFingerprintRegister(void)
  * \param s        Pointer to the Signature to which the current keyword belongs
  * \param str      Should hold an empty string always
  *
- * \retval 0       On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsFingerprintSetup(DetectEngineCtx *de_ctx, Signature *s,
                                      const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_cert_fingerprint_buffer_id);
+    if (DetectBufferSetActiveList(s, g_tls_cert_fingerprint_buffer_id) < 0)
+        return -1;
 
-    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) != 0)
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
         return -1;
 
     return 0;
index 6aedcebed95976200f24516c39a1f48a837423ca..8b5b72759e43691fb72520e95929b124021ef9d3 100644 (file)
@@ -101,12 +101,17 @@ void DetectTlsIssuerRegister(void)
  * \param s        Pointer to the Signature to which the current keyword belongs
  * \param str      Should hold an empty string always
  *
- * \retval 0       On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsIssuerSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_cert_issuer_buffer_id);
-    s->alproto = ALPROTO_TLS;
+    if (DetectBufferSetActiveList(s, g_tls_cert_issuer_buffer_id) < 0)
+        return -1;
+
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
+        return -1;
+
     return 0;
 }
 
index 4f34998aafdaf87c68215bc25a33e8f48ccd35c1..f62bb76be49008641e374a304b8a00077912b541 100644 (file)
@@ -110,13 +110,15 @@ void DetectTlsSerialRegister(void)
  * \param s        Pointer to the Signature to which the current keyword belongs
  * \param str      Should hold an empty string always
  *
- * \retval 0       On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsSerialSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_cert_serial_buffer_id);
+    if (DetectBufferSetActiveList(s, g_tls_cert_serial_buffer_id) < 0)
+        return -1;
 
-    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) != 0)
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
         return -1;
 
     return 0;
index ba30018696b3408562745d4b121e16ea1fb539c3..b2db219f2626f08a803180078ec9177e7a79dd0b 100644 (file)
@@ -100,12 +100,17 @@ void DetectTlsSubjectRegister(void)
  * \param s        Pointer to the Signature to which the current keyword belongs
  * \param str      Should hold an empty string always
  *
- * \retval 0       On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsSubjectSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_cert_subject_buffer_id);
-    s->alproto = ALPROTO_TLS;
+    if (DetectBufferSetActiveList(s, g_tls_cert_subject_buffer_id) < 0)
+        return -1;
+
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
+        return -1;
+
     return 0;
 }
 
index 5ecde459a98089fc2262d6112a9b275e63830b57..5b1e19f693b15a8aa619fd971e62ce7b44baeb19 100644 (file)
@@ -111,12 +111,16 @@ void DetectTlsJa3HashRegister(void)
  * \param s      Pointer to the Signature to which the current keyword belongs
  * \param str    Should hold an empty string always
  *
- * \retval 0 On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsJa3HashSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_ja3_hash_buffer_id);
-    s->alproto = ALPROTO_TLS;
+    if (DetectBufferSetActiveList(s, g_tls_ja3_hash_buffer_id) < 0)
+        return -1;
+
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
+        return -1;
 
     if (RunmodeIsUnittests())
         return 0;
index 5fd7cd5e47bca0e25e48ef735bd7c8d589977a79..747b862733ccf8c6d30aefd3cd89d0c61ecaae55 100644 (file)
@@ -101,12 +101,16 @@ void DetectTlsJa3StringRegister(void)
  * \param s      Pointer to the Signature to which the current keyword belongs
  * \param str    Should hold an empty string always
  *
- * \retval 0 On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsJa3StringSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_ja3_str_buffer_id);
-    s->alproto = ALPROTO_TLS;
+    if (DetectBufferSetActiveList(s, g_tls_ja3_str_buffer_id) < 0)
+        return -1;
+
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
+        return -1;
 
     if (RunmodeIsUnittests())
         return 0;
index 969b9d78ab06fa3e85b1949db4689395a824ace9..ddc170606126543d3fba9319f1f44f4fa32e874c 100644 (file)
@@ -99,12 +99,17 @@ void DetectTlsSniRegister(void)
  * \param s        Pointer to the Signature to which the current keyword belongs
  * \param str      Should hold an empty string always
  *
- * \retval 0       On success
+ * \retval 0  On success
+ * \retval -1 On failure
  */
 static int DetectTlsSniSetup(DetectEngineCtx *de_ctx, Signature *s, const char *str)
 {
-    DetectBufferSetActiveList(s, g_tls_sni_buffer_id);
-    s->alproto = ALPROTO_TLS;
+    if (DetectBufferSetActiveList(s, g_tls_sni_buffer_id) < 0)
+        return -1;
+
+    if (DetectSignatureSetAppProto(s, ALPROTO_TLS) < 0)
+        return -1;
+
     return 0;
 }