http: minor cleanups for detect

In preparation of libhtp rust

Mainly adding some const
pull/12492/head
Philippe Antoine 2 years ago committed by Victor Julien
parent 46c054da3f
commit 439d3766d7

@ -181,7 +181,7 @@ static InspectionBuffer *GetRequestData(DetectEngineThreadCtx *det_ctx,
if (htp_tx_request_headers(tx) == NULL)
return NULL;
htp_header_t *h = (htp_header_t *)htp_tx_request_header(tx, "Cookie");
const htp_header_t *h = htp_tx_request_header(tx, "Cookie");
if (h == NULL || htp_header_value(h) == NULL) {
SCLogDebug("HTTP cookie header not present in this request");
return NULL;
@ -208,7 +208,7 @@ static InspectionBuffer *GetResponseData(DetectEngineThreadCtx *det_ctx,
if (htp_tx_response_headers(tx) == NULL)
return NULL;
htp_header_t *h = (htp_header_t *)htp_tx_response_header(tx, "Set-Cookie");
const htp_header_t *h = htp_tx_response_header(tx, "Set-Cookie");
if (h == NULL || htp_header_value(h) == NULL) {
SCLogDebug("HTTP cookie header not present in this request");
return NULL;

@ -105,7 +105,7 @@ static uint8_t *GetBufferForTX(
size_t i = 0;
size_t no_of_headers = htp_headers_size(headers);
for (; i < no_of_headers; i++) {
htp_header_t *h = htp_headers_get_index(headers, i);
const htp_header_t *h = htp_headers_get_index(headers, i);
size_t size = htp_header_name_len(h) + 2; // for \r\n
if (i == 0)
size += 2;

@ -97,7 +97,7 @@ static uint8_t *GetBufferForTX(
size_t i = 0;
size_t no_of_headers = htp_headers_size(headers);
for (; i < no_of_headers; i++) {
htp_header_t *h = htp_headers_get_index(headers, i);
const htp_header_t *h = htp_headers_get_index(headers, i);
size_t size1 = htp_header_name_len(h);
size_t size2 = htp_header_value_len(h);
@ -575,7 +575,7 @@ static InspectionBuffer *GetHttp1HeaderData(DetectEngineThreadCtx *det_ctx,
hdr_td->cap = no_of_headers;
}
for (size_t i = 0; i < no_of_headers; i++) {
htp_header_t *h = htp_headers_get_index(headers, i);
const htp_header_t *h = htp_headers_get_index(headers, i);
size_t size1 = htp_header_name_len(h);
size_t size2 = htp_header_value_len(h);
size_t size = size1 + size2 + 2;

@ -352,7 +352,7 @@ static InspectionBuffer *GetRawData(DetectEngineThreadCtx *det_ctx,
if (htp_tx_request_headers(tx) == NULL)
return NULL;
htp_header_t *h = (htp_header_t *)htp_tx_request_header(tx, "Host");
const htp_header_t *h = htp_tx_request_header(tx, "Host");
if (h == NULL || htp_header_value(h) == NULL)
return NULL;

@ -87,7 +87,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx,
{
InspectionBuffer *buffer = InspectionBufferGet(det_ctx, list_id);
if (buffer->inspect == NULL) {
bstr *str = NULL;
const bstr *str = NULL;
htp_tx_t *tx = (htp_tx_t *)txv;
if (flow_flags & STREAM_TOSERVER)

@ -85,7 +85,7 @@ static uint8_t *GetBufferForTX(
return NULL;
}
bstr *line = NULL;
const bstr *line = NULL;
htp_table_t *headers;
if (flags & STREAM_TOSERVER) {
if (AppLayerParserGetStateProgress(IPPROTO_TCP, ALPROTO_HTTP1, tx, flags) <=
@ -117,7 +117,7 @@ static uint8_t *GetBufferForTX(
size_t i = 0;
size_t no_of_headers = htp_headers_size(headers);
for (; i < no_of_headers; i++) {
htp_header_t *h = htp_headers_get_index(headers, i);
const htp_header_t *h = htp_headers_get_index(headers, i);
size_t size1 = htp_header_name_len(h);
size_t size2 = htp_header_value_len(h);
size_t size = size1 + size2 + 4;

@ -165,7 +165,7 @@ static InspectionBuffer *GetData(DetectEngineThreadCtx *det_ctx,
if (htp_tx_request_headers(tx) == NULL)
return NULL;
htp_header_t *h = (htp_header_t *)htp_tx_request_header(tx, "User-Agent");
const htp_header_t *h = htp_tx_request_header(tx, "User-Agent");
if (h == NULL || htp_header_value(h) == NULL) {
SCLogDebug("HTTP UA header not present in this request");
return NULL;

Loading…
Cancel
Save