]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #1976 in SNORT/snort3 from ~DERAMADA/snort3:parse_conf_service_nam...
authorMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 3 Feb 2020 14:34:30 +0000 (14:34 +0000)
committerMichael Altizer (mialtize) <mialtize@cisco.com>
Mon, 3 Feb 2020 14:34:30 +0000 (14:34 +0000)
Squashed commit of the following:

commit be557ef9287e921ccaed09b178133315745e56ea
Author: deramada <deramada@cisco.com>
Date:   Thu Jan 30 14:57:50 2020 -0500

    parser: store local copy of service name

src/parser/parse_conf.cc
src/parser/parse_rule.cc

index c1a69c7e5d7aaefd68c42bd92f34b1af4400936e..6b6c3659432708a74bbb3aa09f0d88a25f811b39 100644 (file)
@@ -253,10 +253,7 @@ void add_service_to_otn(SnortConfig* sc, OptTreeNode* otn, const char* svc_name)
     }
 
     if ( !strcmp(svc_name, "http") )
-    {
         add_service_to_otn(sc, otn, "http2");
-        svc_name = "http";
-    }
 
     if (otn->sigInfo.num_services >= sc->max_metadata_services)
     {
index 9ae690d9cc3b2e6acce233bd85c872f2cd24f47e..32470ec6b46dd3f41d9d16417485514905175ef1 100644 (file)
@@ -1242,7 +1242,12 @@ void parse_rule_close(SnortConfig* sc, RuleTreeNode& rtn, OptTreeNode* otn)
     OtnLookupAdd(sc->otn_map, otn);
 
     if ( is_service_protocol(otn->snort_protocol_id) )
-        add_service_to_otn(sc, otn, sc->proto_ref->get_name(otn->snort_protocol_id));
+    {
+        // copy required because the call to add_service_to_otn can 
+        // invalidate the service name pointer
+        std::string service = sc->proto_ref->get_name(otn->snort_protocol_id);
+        add_service_to_otn(sc, otn, service.c_str());
+    }
 
     /*
      * The src/dst port parsing must be done before the Head Nodes are processed, since they must