]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
Merge pull request #845 in SNORT/snort3 from appid_uninitialized_protocol_fix to...
authorTom Peters (thopeter) <thopeter@cisco.com>
Fri, 24 Mar 2017 21:08:15 +0000 (17:08 -0400)
committerTom Peters (thopeter) <thopeter@cisco.com>
Fri, 24 Mar 2017 21:08:15 +0000 (17:08 -0400)
Squashed commit of the following:

commit 5015272dcdba3db74196f847541013abdae2d494
Author: davis mcpherson <davmcphe.cisco.com>
Date:   Fri Mar 24 10:44:03 2017 -0400

    ensure the protocol variable passed in when instantiating a lua detector is initialized.

src/network_inspectors/appid/lua_detector_module.cc

index efc90aa5dbda34597ce827deea4a1e93e87f33c6..394fde58aa1caa9218ef3dde0662aabb65ca9005 100644 (file)
@@ -110,8 +110,7 @@ static inline bool get_lua_ns(lua_State* L, const char* const ns)
     return true;
 }
 
-static inline bool get_lua_field(
-    lua_State* L, int table, const char* field, std::string& out)
+static inline bool get_lua_field(lua_State* L, int table, const char* field, std::string& out)
 {
     lua_getfield(L, table, field);
     bool result = lua_isstring(L, -1);
@@ -122,25 +121,27 @@ static inline bool get_lua_field(
     return result;
 }
 
-static inline bool get_lua_field(
-    lua_State* L, int table, const char* field, int& out)
+static inline bool get_lua_field(lua_State* L, int table, const char* field, int& out)
 {
     lua_getfield(L, table, field);
     bool result = lua_isnumber(L, -1);
     if ( result )
         out = lua_tointeger(L, -1);
+    else
+        out = 0;
 
     lua_pop(L, 1);
     return result;
 }
 
-static inline bool get_lua_field(
-    lua_State* L, int table, const char* field, IpProtocol& out)
+static inline bool get_lua_field(lua_State* L, int table, const char* field, IpProtocol& out)
 {
     lua_getfield(L, table, field);
     bool result = lua_isnumber(L, -1);
     if ( result )
         out = (IpProtocol)lua_tointeger(L, -1);
+    else
+        out = IpProtocol::PROTO_NOT_SET;
 
     lua_pop(L, 1);
     return result;
@@ -329,7 +330,7 @@ static LuaDetector* create_lua_detector(lua_State* L, const char* detectorName,
 {
     LuaDetector* detector = nullptr;
     std::string detector_name;
-    IpProtocol proto;
+    IpProtocol proto = IpProtocol::PROTO_NOT_SET;
 
     Lua::ManageStack mgr(L);
     lua_getglobal(L, "DetectorPackageInfo");