]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
app-layer-parser: don't overwrite stream_depth value
authorGiuseppe Longo <glongo@stamus-networks.com>
Thu, 18 Jan 2018 11:49:53 +0000 (12:49 +0100)
committerVictor Julien <victor@inliniac.net>
Tue, 7 Aug 2018 11:49:34 +0000 (13:49 +0200)
When an app-layer parser is enabled, it could set its
own stream_depth value calling the API AppLayerParserSetStreamDepth.

Then, the function AppLayerParserPostStreamSetup will replace
the stream_depth value already set with stream_config.reassembly_depth.

To avoid overwriting, in AppLayerParserSetStreamDepth API a flag
will be set internally to specify that a value is already set.

src/app-layer-parser.c
src/app-layer-parser.h

index a91ad052f5aa8664d882bb59aaa2f5fc0ae6e88c..cd42cfc0572bcd0000143017e2e311adbdd4d125 100644 (file)
@@ -209,8 +209,11 @@ void AppLayerParserPostStreamSetup(void)
     /* lets set a default value for stream_depth */
     for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
         for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
-            alp_ctx.ctxs[flow_proto][alproto].stream_depth =
-                stream_config.reassembly_depth;
+            if (!(alp_ctx.ctxs[flow_proto][alproto].flags &
+                APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET)) {
+                alp_ctx.ctxs[flow_proto][alproto].stream_depth =
+                    stream_config.reassembly_depth;
+            }
         }
     }
 }
@@ -1315,6 +1318,8 @@ void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t st
     SCEnter();
 
     alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth = stream_depth;
+    alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].flags |=
+        APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET;
 
     SCReturn;
 }
index 61d28db61013627db2ef9c1fc63b9e51c6ec1385..cec6bf1ac1da223688012d4236fe64ba02ec03bd 100644 (file)
@@ -39,6 +39,7 @@
 
 /* Flags for AppLayerParserProtoCtx. */
 #define APP_LAYER_PARSER_OPT_ACCEPT_GAPS        BIT_U64(0)
+#define APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET   BIT_U64(1)
 
 /* applies to DetectFlags uint64_t field */