protodetect: use dynamic number of app-layer protos

for expectation_proto

Ticket: 5053
pull/12358/head
Philippe Antoine 10 months ago committed by Victor Julien
parent 6b7349dbc1
commit 61657c8ec6

@ -161,8 +161,11 @@ typedef struct AppLayerProtoDetectCtx_ {
* ipproto. */ * ipproto. */
const char *alproto_names[ALPROTO_MAX]; const char *alproto_names[ALPROTO_MAX];
/* Protocol expectations, like ftp-data on tcp */ /* Protocol expectations, like ftp-data on tcp.
uint8_t expectation_proto[ALPROTO_MAX]; * It should be allocated to contain ALPROTO_MAX
* app-layer protocols. For each protocol, an iptype
* is referenced (or 0 if there is no expectation). */
uint8_t *expectation_proto;
} AppLayerProtoDetectCtx; } AppLayerProtoDetectCtx;
typedef struct AppLayerProtoDetectAliases_ { typedef struct AppLayerProtoDetectAliases_ {
@ -1721,6 +1724,11 @@ int AppLayerProtoDetectSetup(void)
} }
} }
// to realloc when dynamic protos are added
alpd_ctx.expectation_proto = SCCalloc(ALPROTO_MAX, sizeof(uint8_t));
if (unlikely(alpd_ctx.expectation_proto == NULL)) {
FatalError("Unable to alloc expectation_proto.");
}
AppLayerExpectationSetup(); AppLayerExpectationSetup();
SCReturnInt(0); SCReturnInt(0);
@ -1752,6 +1760,9 @@ int AppLayerProtoDetectDeSetup(void)
} }
} }
SCFree(alpd_ctx.expectation_proto);
alpd_ctx.expectation_proto = NULL;
SpmDestroyGlobalThreadCtx(alpd_ctx.spm_global_thread_ctx); SpmDestroyGlobalThreadCtx(alpd_ctx.spm_global_thread_ctx);
AppLayerProtoDetectFreeAliases(); AppLayerProtoDetectFreeAliases();

Loading…
Cancel
Save