|
|
@ -97,10 +97,12 @@ static void DetectEngineBufferHttpClientBodies(DetectEngineCtx *de_ctx,
|
|
|
|
size_t txs = list_size(htp_state->connp->conn->transactions) - tmp_idx;
|
|
|
|
size_t txs = list_size(htp_state->connp->conn->transactions) - tmp_idx;
|
|
|
|
/* no transactions?! cool. get out of here */
|
|
|
|
/* no transactions?! cool. get out of here */
|
|
|
|
if (txs == 0) {
|
|
|
|
if (txs == 0) {
|
|
|
|
|
|
|
|
det_ctx->hcbd_buffers_list_len = 0;
|
|
|
|
goto end;
|
|
|
|
goto end;
|
|
|
|
} else if (txs > det_ctx->hcbd_buffers_list_len) {
|
|
|
|
} else if (txs > det_ctx->hcbd_buffers_list_len) {
|
|
|
|
det_ctx->hcbd = SCRealloc(det_ctx->hcbd, txs * sizeof(HttpReassembledBody));
|
|
|
|
det_ctx->hcbd = SCRealloc(det_ctx->hcbd, txs * sizeof(HttpReassembledBody));
|
|
|
|
if (det_ctx->hcbd == NULL) {
|
|
|
|
if (det_ctx->hcbd == NULL) {
|
|
|
|
|
|
|
|
det_ctx->hcbd_buffers_list_len = 0;
|
|
|
|
goto end;
|
|
|
|
goto end;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -233,6 +235,7 @@ int DetectEngineRunHttpClientBodyMpm(DetectEngineCtx *de_ctx,
|
|
|
|
DetectEngineBufferHttpClientBodies(de_ctx, det_ctx, f, htp_state);
|
|
|
|
DetectEngineBufferHttpClientBodies(de_ctx, det_ctx, f, htp_state);
|
|
|
|
FLOWLOCK_UNLOCK(f);
|
|
|
|
FLOWLOCK_UNLOCK(f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (det_ctx->hcbd != NULL && det_ctx->hcbd_buffers_list_len) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
if (det_ctx->hcbd[i].buffer_len == 0)
|
|
|
|
if (det_ctx->hcbd[i].buffer_len == 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
@ -242,6 +245,7 @@ int DetectEngineRunHttpClientBodyMpm(DetectEngineCtx *de_ctx,
|
|
|
|
det_ctx->hcbd[i].buffer_len,
|
|
|
|
det_ctx->hcbd[i].buffer_len,
|
|
|
|
flags);
|
|
|
|
flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return cnt;
|
|
|
|
return cnt;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -272,6 +276,7 @@ int DetectEngineInspectHttpClientBody(DetectEngineCtx *de_ctx,
|
|
|
|
DetectEngineBufferHttpClientBodies(de_ctx, det_ctx, f, alstate);
|
|
|
|
DetectEngineBufferHttpClientBodies(de_ctx, det_ctx, f, alstate);
|
|
|
|
FLOWLOCK_UNLOCK(f);
|
|
|
|
FLOWLOCK_UNLOCK(f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (det_ctx->hcbd != NULL && det_ctx->hcbd_buffers_list_len) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
uint8_t *hcbd_buffer = det_ctx->hcbd[i].buffer;
|
|
|
|
uint8_t *hcbd_buffer = det_ctx->hcbd[i].buffer;
|
|
|
|
uint32_t hcbd_buffer_len = det_ctx->hcbd[i].buffer_len;
|
|
|
|
uint32_t hcbd_buffer_len = det_ctx->hcbd[i].buffer_len;
|
|
|
@ -292,6 +297,7 @@ int DetectEngineInspectHttpClientBody(DetectEngineCtx *de_ctx,
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SCReturnInt(r);
|
|
|
|
SCReturnInt(r);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -304,9 +310,11 @@ int DetectEngineInspectHttpClientBody(DetectEngineCtx *de_ctx,
|
|
|
|
void DetectEngineCleanHCBDBuffers(DetectEngineThreadCtx *det_ctx)
|
|
|
|
void DetectEngineCleanHCBDBuffers(DetectEngineThreadCtx *det_ctx)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (det_ctx->hcbd != NULL && det_ctx->hcbd_buffers_list_len) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
for (i = 0; i < det_ctx->hcbd_buffers_list_len; i++) {
|
|
|
|
det_ctx->hcbd[i].buffer_len = 0;
|
|
|
|
det_ctx->hcbd[i].buffer_len = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|