]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer: check name vs proto mapping in registration
authorVictor Julien <vjulien@oisf.net>
Tue, 20 Dec 2022 10:34:45 +0000 (11:34 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 20 Dec 2022 10:34:45 +0000 (11:34 +0100)
src/app-layer-register.c

index 7233bf4b7f78e99dbaa5f78ea4cf8ad531e4c1fb..c4441d9f7c5b48c29d514a0a75a48c546129659e 100644 (file)
@@ -47,6 +47,8 @@ AppProto AppLayerRegisterProtocolDetection(const struct AppLayerParser *p, int e
     if (alproto == ALPROTO_UNKNOWN || alproto == ALPROTO_FAILED)
         FatalError("Unknown or invalid AppProto '%s'.", p->name);
 
+    BUG_ON(strcmp(p->name, AppProtoToString(alproto)) != 0);
+
     ip_proto_str = IpProtoToString(p->ip_proto);
     if (ip_proto_str == NULL)
         FatalError("Unknown or unsupported ip_proto field in parser '%s'", p->name);
@@ -102,6 +104,8 @@ int AppLayerRegisterParser(const struct AppLayerParser *p, AppProto alproto)
     if (alproto == ALPROTO_UNKNOWN || alproto >= ALPROTO_FAILED)
         FatalError("Unknown or invalid AppProto '%s'.", p->name);
 
+    BUG_ON(strcmp(p->name, AppProtoToString(alproto)) != 0);
+
     ip_proto_str = IpProtoToString(p->ip_proto);
     if (ip_proto_str == NULL)
         FatalError("Unknown or unsupported ip_proto field in parser '%s'", p->name);