app-layer-parser: don't overwrite stream_depth value

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.
pull/3448/head
Giuseppe Longo 8 years ago committed by Victor Julien
parent 7c884e0850
commit 397f5f5fdf

@ -209,11 +209,14 @@ void AppLayerParserPostStreamSetup(void)
/* lets set a default value for stream_depth */ /* lets set a default value for stream_depth */
for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) { for (flow_proto = 0; flow_proto < FLOW_PROTO_DEFAULT; flow_proto++) {
for (alproto = 0; alproto < ALPROTO_MAX; alproto++) { for (alproto = 0; alproto < ALPROTO_MAX; alproto++) {
if (!(alp_ctx.ctxs[flow_proto][alproto].flags &
APP_LAYER_PARSER_OPT_STREAM_DEPTH_SET)) {
alp_ctx.ctxs[flow_proto][alproto].stream_depth = alp_ctx.ctxs[flow_proto][alproto].stream_depth =
stream_config.reassembly_depth; stream_config.reassembly_depth;
} }
} }
} }
}
int AppLayerParserDeSetup(void) int AppLayerParserDeSetup(void)
{ {
@ -1315,6 +1318,8 @@ void AppLayerParserSetStreamDepth(uint8_t ipproto, AppProto alproto, uint32_t st
SCEnter(); SCEnter();
alp_ctx.ctxs[FlowGetProtoMapping(ipproto)][alproto].stream_depth = stream_depth; 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; SCReturn;
} }

@ -39,6 +39,7 @@
/* Flags for AppLayerParserProtoCtx. */ /* Flags for AppLayerParserProtoCtx. */
#define APP_LAYER_PARSER_OPT_ACCEPT_GAPS BIT_U64(0) #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 */ /* applies to DetectFlags uint64_t field */

Loading…
Cancel
Save