#define BUFFER_STEP 50
-static inline int HCBDCreateSpace(DetectEngineThreadCtx *det_ctx, uint16_t size)
+static inline int HCBDCreateSpace(DetectEngineThreadCtx *det_ctx, uint64_t size)
{
+ if (size >= USHRT_MAX)
+ return -1;
+
void *ptmp;
if (size > det_ctx->hcbd_buffers_size) {
ptmp = SCRealloc(det_ctx->hcbd,
memset(det_ctx->hcbd + det_ctx->hcbd_buffers_size, 0, BUFFER_STEP * sizeof(HttpReassembledBody));
det_ctx->hcbd_buffers_size += BUFFER_STEP;
- for (int i = det_ctx->hcbd_buffers_list_len; i < (size); i++) {
+ uint16_t i;
+ for (i = det_ctx->hcbd_buffers_list_len; i < ((uint16_t)size); i++) {
det_ctx->hcbd[i].buffer_len = 0;
det_ctx->hcbd[i].offset = 0;
}
uint64_t base_inspect_id = AppLayerParserGetTransactionInspectId(f->alparser, flags);
BUG_ON(base_inspect_id > tx_id);
/* see how many space we need for the current tx_id */
- uint16_t txs = (tx_id - base_inspect_id) + 1;
-
+ uint64_t txs = (tx_id - base_inspect_id) + 1;
if (HCBDCreateSpace(det_ctx, txs) < 0)
goto end;
return det_ctx->hcbd[(tx_id - det_ctx->hcbd_start_tx_id)].buffer;
}
} else {
- uint16_t txs = (tx_id - det_ctx->hcbd_start_tx_id) + 1;
+ uint64_t txs = (tx_id - det_ctx->hcbd_start_tx_id) + 1;
if (HCBDCreateSpace(det_ctx, txs) < 0)
goto end; /* let's consider it as stage not done for now */
#define BUFFER_STEP 50
-static inline int HHDCreateSpace(DetectEngineThreadCtx *det_ctx, uint16_t size)
+static inline int HHDCreateSpace(DetectEngineThreadCtx *det_ctx, uint64_t size)
{
+ if (size >= USHRT_MAX)
+ return -1;
+
void *ptmp;
if (size > det_ctx->hhd_buffers_size) {
ptmp = SCRealloc(det_ctx->hhd_buffers,
uint64_t base_inspect_id = AppLayerParserGetTransactionInspectId(f->alparser, flags);
BUG_ON(base_inspect_id > tx_id);
/* see how many space we need for the current tx_id */
- uint16_t txs = (tx_id - base_inspect_id) + 1;
-
+ uint64_t txs = (tx_id - base_inspect_id) + 1;
if (HHDCreateSpace(det_ctx, txs) < 0)
goto end;
/* otherwise fall through */
} else {
/* not enough space, lets expand */
- uint16_t txs = (tx_id - det_ctx->hhd_start_tx_id) + 1;
+ uint64_t txs = (tx_id - det_ctx->hhd_start_tx_id) + 1;
if (HHDCreateSpace(det_ctx, txs) < 0)
goto end;
#define BUFFER_STEP 50
-static inline int HSBDCreateSpace(DetectEngineThreadCtx *det_ctx, uint16_t size)
+static inline int HSBDCreateSpace(DetectEngineThreadCtx *det_ctx, uint64_t size)
{
+ if (size >= USHRT_MAX)
+ return -1;
+
void *ptmp;
if (size > det_ctx->hsbd_buffers_size) {
ptmp = SCRealloc(det_ctx->hsbd,
memset(det_ctx->hsbd + det_ctx->hsbd_buffers_size, 0, BUFFER_STEP * sizeof(HttpReassembledBody));
det_ctx->hsbd_buffers_size += BUFFER_STEP;
}
- for (int i = det_ctx->hsbd_buffers_list_len; i < (size); i++) {
+ uint16_t i;
+ for (i = det_ctx->hsbd_buffers_list_len; i < ((uint16_t)size); i++) {
det_ctx->hsbd[i].buffer_len = 0;
det_ctx->hsbd[i].offset = 0;
}
uint64_t base_inspect_id = AppLayerParserGetTransactionInspectId(f->alparser, flags);
BUG_ON(base_inspect_id > tx_id);
/* see how many space we need for the current tx_id */
- uint16_t txs = (tx_id - base_inspect_id) + 1;
-
+ uint64_t txs = (tx_id - base_inspect_id) + 1;
if (HSBDCreateSpace(det_ctx, txs) < 0)
goto end;
index = (tx_id - base_inspect_id);
return det_ctx->hsbd[(tx_id - det_ctx->hsbd_start_tx_id)].buffer;
}
} else {
- uint16_t txs = (tx_id - det_ctx->hsbd_start_tx_id) + 1;
+ uint64_t txs = (tx_id - det_ctx->hsbd_start_tx_id) + 1;
if (HSBDCreateSpace(det_ctx, txs) < 0)
goto end;