]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Bug 1329: error out on invalid rule protocol
authorVictor Julien <victor@inliniac.net>
Fri, 5 Dec 2014 13:32:56 +0000 (14:32 +0100)
committerVictor Julien <victor@inliniac.net>
Thu, 11 Dec 2014 10:51:12 +0000 (11:51 +0100)
Due to a logic error in AppLayerProtoDetectGetProtoByName invalid
protocols would not be detected as such. Instead of ALPROTO_UNKNOWN
ALPROTO_MAX was returned.

Bug #1329

src/app-layer-detect-proto.c

index b5b380cdbb2226371c240dcf5a9c8681b3340a85..762d140b1111d27cc54502ef148aea884c040fcf 100644 (file)
@@ -1729,19 +1729,17 @@ AppProto AppLayerProtoDetectGetProtoByName(char *alproto_name)
 {
     SCEnter();
 
-    AppProto a = ALPROTO_UNKNOWN;
-
+    AppProto a;
     for (a = 0; a < ALPROTO_MAX; a++) {
         if (alpd_ctx.alproto_names[a] != NULL &&
             strlen(alpd_ctx.alproto_names[a]) == strlen(alproto_name) &&
             (SCMemcmp(alpd_ctx.alproto_names[a], alproto_name, strlen(alproto_name)) == 0))
         {
-            goto end;
+            SCReturnCT(a, "AppProto");
         }
     }
 
- end:
-    SCReturnCT(a, "AppProto");
+    SCReturnCT(ALPROTO_UNKNOWN, "AppProto");
 }
 
 char *AppLayerProtoDetectGetProtoName(AppProto alproto)