]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
proto/names: add SCTP if not defined in system 5806/head
authorVictor Julien <victor@inliniac.net>
Mon, 18 Jan 2021 12:56:32 +0000 (13:56 +0100)
committerShivani Bhardwaj <shivanib134@gmail.com>
Fri, 29 Jan 2021 12:17:16 +0000 (17:47 +0530)
If SCTP is missing from /etc/protocols, add it manually.

(cherry picked from commit bf00285d0acf87c794f6569eb51d1f7d1247a0da)

src/util-proto-name.c

index a7954c3020ecf00cc0c2c2b3e3cabf4e3ad9309e..fbd76a51d1091ed5cab62450511ff51af58341d3 100644 (file)
 char *known_proto[256];
 static int init_once = 0;
 
+static void SetDefault(const uint8_t proto, const char *string)
+{
+    if (known_proto[proto] == NULL) {
+        known_proto[proto] = SCStrdup(string);
+        if (unlikely(known_proto[proto] == NULL)) {
+            FatalError(SC_ERR_MEM_ALLOC, "failed to alloc protocol name");
+        }
+    }
+}
+
 /**
  *  \brief  Function to load the protocol names from the specified protocol
  *          file.
@@ -86,6 +96,8 @@ void SCProtoNameInit()
         }
         fclose(fp);
     }
+
+    SetDefault(IPPROTO_SCTP, "SCTP");
 }
 
 /**