]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #2425 in SNORT/snort3 from ~CLJUDGE/snort3:ssl_check_host_for_null...
authorShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Thu, 27 Aug 2020 20:59:14 +0000 (20:59 +0000)
committerShravan Rangarajuvenkata (shrarang) <shrarang@cisco.com>
Thu, 27 Aug 2020 20:59:14 +0000 (20:59 +0000)
Squashed commit of the following:

commit 2d74e652df3a89b010de5eb38bfea7e2dc955efe
Author: cljudge <cljudge@cisco.com>
Date:   Tue Aug 18 01:26:19 2020 -0400

    appid: adding check for nullptr before setting tls host

src/network_inspectors/appid/appid_session_api.h
src/network_inspectors/appid/test/appid_session_api_test.cc

index bb5ab6ecc42243e79f05b77ecd2c478d430cbb7e..4a061c451e49c2ff8403f5438bab2d061ca9eff8 100644 (file)
@@ -188,9 +188,12 @@ private:
 
     void set_tls_host(const char* host)
     {
-        if (tls_host)
-            snort_free(tls_host);
-        tls_host = snort_strdup(host);
+        if (host)
+        {
+            if (tls_host)
+                snort_free(tls_host);
+            tls_host = snort_strdup(host);
+        }
     }
 
     friend AppIdSession;
index 9fd0de7922bde58ecc77df60b90bdb6099d3c7d7..093d86a09331ba40839d07addf39691f742dd9b0 100644 (file)
@@ -131,10 +131,14 @@ TEST(appid_session_api, get_tls_host)
 {
     AppidChangeBits change_bits;
     change_bits.set(APPID_TLSHOST_BIT);
+    mock_session->tsession->set_tls_host(nullptr, 0, change_bits);
+    mock_session->set_tls_host(change_bits);
+    const char* val = mock_session->get_api().get_tls_host();                                       
+    STRCMP_EQUAL(val, nullptr);                   
     char* host = snort_strdup(APPID_UT_TLS_HOST);
     mock_session->tsession->set_tls_host(host, 0, change_bits);
     mock_session->set_tls_host(change_bits);
-    const char* val = mock_session->get_api().get_tls_host();
+    val = mock_session->get_api().get_tls_host();
     STRCMP_EQUAL(val, APPID_UT_TLS_HOST);
 }