protodetect: use dynamic number of app-layer protos

for expectation_proto

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

@ -161,8 +161,11 @@ typedef struct AppLayerProtoDetectCtx_ {
* ipproto. */
const char *alproto_names[ALPROTO_MAX];
/* Protocol expectations, like ftp-data on tcp */
uint8_t expectation_proto[ALPROTO_MAX];
/* Protocol expectations, like ftp-data on tcp.
* 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;
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();
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);
AppLayerProtoDetectFreeAliases();

Loading…
Cancel
Save