util/spm: explicit needle_len is u16

So, stack allocation is bounded

Ticket: 8001
pull/15486/head
Philippe Antoine 4 months ago committed by Victor Julien
parent 9c76480ac3
commit 25bf59f238

@ -37,11 +37,11 @@
* Convert haystack data to lowercase before inspecting it with
* `memmem`. Do this in a sliding window manner. */
static const uint8_t *SCMemimem(const uint8_t *haystack, uint32_t haystack_len,
const uint8_t *needle, const uint32_t needle_len)
const uint8_t *needle, const uint16_t needle_len)
{
if (needle_len > haystack_len)
return NULL;
uint32_t slice_size = MAX(MIN(haystack_len, 128), needle_len * 3);
uint32_t slice_size = MAX(MIN(haystack_len, 128), (uint32_t)needle_len * 3);
uint8_t slice[slice_size];
uint32_t o = 0;
do {

@ -26,7 +26,7 @@
#ifdef HAVE_MEMMEM
typedef struct SpmMmCtx_ {
uint32_t needle_len;
uint16_t needle_len;
int nocase;
uint8_t needle[];
} SpmMmCtx;

Loading…
Cancel
Save