detect/mpm: use fixed constant for stack allocation

instead of smaller run-time value.
Allows easier reading of the code for unbounded stack allocations

Ticket: 8001
pull/14337/head
Philippe Antoine 9 months ago committed by Victor Julien
parent 71c95fe670
commit 190ae4c6f9

@ -216,8 +216,8 @@ static void AppendTransformsToPname(
/* create comma separated string of the names of the
* transforms and then shorten it if necessary. Finally
* use it to construct the 'profile' name for the engine */
char xforms[left + 1];
memset(xforms, 0, left + 1);
char xforms[DETECT_PROFILE_NAME_LEN + 1];
memset(xforms, 0, DETECT_PROFILE_NAME_LEN + 1);
for (int i = 0; i < transforms->cnt; i++) {
char ttstr[64];
(void)snprintf(ttstr, sizeof(ttstr), "%s,",
@ -1524,6 +1524,7 @@ void MpmStoreReportStats(const DetectEngineCtx *de_ctx)
HashListTableBucket *htb = NULL;
uint32_t stats[MPMB_MAX] = {0};
DEBUG_VALIDATE_BUG_ON(de_ctx->buffer_type_id > UINT16_MAX);
int app_mpms_cnt = de_ctx->buffer_type_id;
uint32_t appstats[app_mpms_cnt + 1]; // +1 to silence scan-build
memset(&appstats, 0x00, sizeof(appstats));

@ -758,10 +758,11 @@ enum DetectBufferMpmType {
DETECT_BUFFER_MPM_TYPE_SIZE,
};
#define DETECT_PROFILE_NAME_LEN 32
/** \brief one time registration of keywords at start up */
typedef struct DetectBufferMpmRegistry_ {
const char *name;
char pname[32]; /**< name used in profiling */
char pname[DETECT_PROFILE_NAME_LEN]; /**< name used in profiling */
int direction; /**< SIG_FLAG_TOSERVER or SIG_FLAG_TOCLIENT */
int16_t sm_list;
int16_t sm_list_base;

Loading…
Cancel
Save