From: Philippe Antoine Date: Fri, 24 Jan 2025 16:42:39 +0000 (+0100) Subject: http: minor cleanups for detect X-Git-Tag: suricata-8.0.0-beta1~504 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=439d3766d71c6525d87d17a15bd09f6d99459f2b;p=thirdparty%2Fsuricata.git http: minor cleanups for detect In preparation of libhtp rust Mainly adding some const --- diff --git a/src/detect-http-cookie.c b/src/detect-http-cookie.c index 7397edf079..865a88d8a1 100644 --- a/src/detect-http-cookie.c +++ b/src/detect-http-cookie.c @@ -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; diff --git a/src/detect-http-header-names.c b/src/detect-http-header-names.c index eb941434c7..fa2f1c4be2 100644 --- a/src/detect-http-header-names.c +++ b/src/detect-http-header-names.c @@ -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; diff --git a/src/detect-http-header.c b/src/detect-http-header.c index f031a3790f..14cfdc8703 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -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; diff --git a/src/detect-http-host.c b/src/detect-http-host.c index 0df8911eeb..a86625d8af 100644 --- a/src/detect-http-host.c +++ b/src/detect-http-host.c @@ -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; diff --git a/src/detect-http-protocol.c b/src/detect-http-protocol.c index 8f50693be0..0c2d9cb71b 100644 --- a/src/detect-http-protocol.c +++ b/src/detect-http-protocol.c @@ -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) diff --git a/src/detect-http-start.c b/src/detect-http-start.c index 098b866eb0..9d1c539e60 100644 --- a/src/detect-http-start.c +++ b/src/detect-http-start.c @@ -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; diff --git a/src/detect-http-ua.c b/src/detect-http-ua.c index a643bf913f..2a539d69df 100644 --- a/src/detect-http-ua.c +++ b/src/detect-http-ua.c @@ -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;