From b1fa9755035a5ebfc2d67ea69d8436fb52d8f693 Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Sat, 23 Sep 2023 09:26:12 +0200 Subject: [PATCH] detect/content-inspect: remove const casting --- src/detect-dns-query.c | 2 +- src/detect-engine-frame.c | 9 ++------- src/detect-engine-payload.c | 4 ++-- src/detect-engine.c | 5 ++--- src/detect-file-data.c | 2 +- src/detect-filemagic.c | 2 +- src/detect-filename.c | 2 +- src/detect-http-client-body.c | 5 ++--- src/detect-http-header.c | 2 +- src/detect-http2.c | 2 +- src/detect-ike-vendor.c | 2 +- src/detect-krb5-cname.c | 2 +- src/detect-krb5-sname.c | 2 +- src/detect-mqtt-subscribe-topic.c | 2 +- src/detect-mqtt-unsubscribe-topic.c | 2 +- src/detect-quic-cyu-hash.c | 2 +- src/detect-quic-cyu-string.c | 2 +- src/detect-template-rust-buffer.c | 2 +- src/detect-tls-certs.c | 2 +- 19 files changed, 23 insertions(+), 30 deletions(-) diff --git a/src/detect-dns-query.c b/src/detect-dns-query.c index d2dbe8e990..a0bf46f386 100644 --- a/src/detect-dns-query.c +++ b/src/detect-dns-query.c @@ -115,7 +115,7 @@ static uint8_t DetectEngineInspectDnsQuery(DetectEngineCtx *de_ctx, DetectEngine break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-engine-frame.c b/src/detect-engine-frame.c index 0ed70757d5..71ac9d3d16 100644 --- a/src/detect-engine-frame.c +++ b/src/detect-engine-frame.c @@ -306,13 +306,8 @@ static int DetectFrameInspectUdp(DetectEngineThreadCtx *det_ctx, if (buffer->inspect == NULL) return DETECT_ENGINE_INSPECT_SIG_NO_MATCH; - const uint32_t data_len = buffer->inspect_len; - const uint8_t *data = buffer->inspect; - - // PrintRawDataFp(stdout, data, data_len); - const bool match = DetectEngineContentInspection(det_ctx->de_ctx, det_ctx, s, engine->smd, p, - p->flow, (uint8_t *)data, data_len, 0, buffer->flags, + p->flow, buffer->inspect, buffer->inspect_len, 0, buffer->flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_FRAME); if (match) { SCLogDebug("match!"); @@ -479,7 +474,7 @@ static int FrameStreamDataInspectFunc( BUG_ON(fsd->frame->len > 0 && (int64_t)data_len > fsd->frame->len); const bool match = DetectEngineContentInspection(det_ctx->de_ctx, det_ctx, s, engine->smd, p, - p->flow, (uint8_t *)data, data_len, data_offset, buffer->flags, + p->flow, data, data_len, data_offset, buffer->flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_FRAME); if (match) { SCLogDebug("DETECT_ENGINE_INSPECT_SIG_MATCH"); diff --git a/src/detect-engine-payload.c b/src/detect-engine-payload.c index 7da3c3b81f..d051303ddb 100644 --- a/src/detect-engine-payload.c +++ b/src/detect-engine-payload.c @@ -227,7 +227,7 @@ static int StreamContentInspectFunc( #endif const bool match = DetectEngineContentInspection(smd->de_ctx, smd->det_ctx, smd->s, - smd->s->sm_arrays[DETECT_SM_LIST_PMATCH], NULL, smd->f, (uint8_t *)data, data_len, 0, + smd->s->sm_arrays[DETECT_SM_LIST_PMATCH], NULL, smd->f, data, data_len, 0, 0, // TODO DETECT_ENGINE_CONTENT_INSPECTION_MODE_STREAM); if (match) { @@ -282,7 +282,7 @@ static int StreamContentInspectEngineFunc( #endif const bool match = DetectEngineContentInspection(smd->de_ctx, smd->det_ctx, smd->s, smd->smd, - NULL, smd->f, (uint8_t *)data, data_len, 0, 0, // TODO + NULL, smd->f, data, data_len, 0, 0, // TODO DETECT_ENGINE_CONTENT_INSPECTION_MODE_STREAM); if (match) { SCReturnInt(1); diff --git a/src/detect-engine.c b/src/detect-engine.c index a4ce212654..58aee1bfc0 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -2206,9 +2206,8 @@ uint8_t DetectEngineInspectBufferGeneric(DetectEngineCtx *de_ctx, DetectEngineTh /* Inspect all the uricontents fetched on each * transaction at the app layer */ - const bool match = - DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, (uint8_t *)data, - data_len, offset, ci_flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); + const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, data, + data_len, offset, ci_flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; } else { diff --git a/src/detect-file-data.c b/src/detect-file-data.c index f31715adda..533fc8441d 100644 --- a/src/detect-file-data.c +++ b/src/detect-file-data.c @@ -415,7 +415,7 @@ uint8_t DetectEngineInspectFiledata(DetectEngineCtx *de_ctx, DetectEngineThreadC ciflags |= DETECT_CI_FLAGS_START; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, ciflags, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, ciflags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-filemagic.c b/src/detect-filemagic.c index 7ade159fb5..b7a737e6c7 100644 --- a/src/detect-filemagic.c +++ b/src/detect-filemagic.c @@ -321,7 +321,7 @@ static uint8_t DetectEngineInspectFilemagic(DetectEngineCtx *de_ctx, DetectEngin continue; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-filename.c b/src/detect-filename.c index 88e5808624..10646f019f 100644 --- a/src/detect-filename.c +++ b/src/detect-filename.c @@ -258,7 +258,7 @@ static uint8_t DetectEngineInspectFilename(DetectEngineCtx *de_ctx, DetectEngine continue; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-http-client-body.c b/src/detect-http-client-body.c index 1d3d7a87cc..9e14b1b49f 100644 --- a/src/detect-http-client-body.c +++ b/src/detect-http-client-body.c @@ -325,9 +325,8 @@ static uint8_t DetectEngineInspectBufferHttpBody(DetectEngineCtx *de_ctx, /* Inspect all the uricontents fetched on each * transaction at the app layer */ - const bool match = - DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, (uint8_t *)data, - data_len, offset, ci_flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); + const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, data, + data_len, offset, ci_flags, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; } diff --git a/src/detect-http-header.c b/src/detect-http-header.c index a4596c4085..91e17d8863 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -545,7 +545,7 @@ static uint8_t DetectEngineInspectHttp2Header(DetectEngineCtx *de_ctx, break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-http2.c b/src/detect-http2.c index a1ede96382..a65115a14c 100644 --- a/src/detect-http2.c +++ b/src/detect-http2.c @@ -703,7 +703,7 @@ static uint8_t DetectEngineInspectHttp2HeaderName(DetectEngineCtx *de_ctx, break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-ike-vendor.c b/src/detect-ike-vendor.c index f5c5b94f35..3b84da2666 100644 --- a/src/detect-ike-vendor.c +++ b/src/detect-ike-vendor.c @@ -156,7 +156,7 @@ static uint8_t DetectEngineInspectIkeVendor(DetectEngineCtx *de_ctx, DetectEngin break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-krb5-cname.c b/src/detect-krb5-cname.c index 8664f2bc28..d509116ee7 100644 --- a/src/detect-krb5-cname.c +++ b/src/detect-krb5-cname.c @@ -104,7 +104,7 @@ static uint8_t DetectEngineInspectKrb5CName(DetectEngineCtx *de_ctx, DetectEngin break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-krb5-sname.c b/src/detect-krb5-sname.c index 1e4ae24a4b..9fbe550b02 100644 --- a/src/detect-krb5-sname.c +++ b/src/detect-krb5-sname.c @@ -105,7 +105,7 @@ static uint8_t DetectEngineInspectKrb5SName(DetectEngineCtx *de_ctx, DetectEngin break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-mqtt-subscribe-topic.c b/src/detect-mqtt-subscribe-topic.c index 9eaf39d302..9e0058785e 100644 --- a/src/detect-mqtt-subscribe-topic.c +++ b/src/detect-mqtt-subscribe-topic.c @@ -108,7 +108,7 @@ static uint8_t DetectEngineInspectMQTTSubscribeTopic(DetectEngineCtx *de_ctx, break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-mqtt-unsubscribe-topic.c b/src/detect-mqtt-unsubscribe-topic.c index 268d72bc87..297142dd83 100644 --- a/src/detect-mqtt-unsubscribe-topic.c +++ b/src/detect-mqtt-unsubscribe-topic.c @@ -108,7 +108,7 @@ static uint8_t DetectEngineInspectMQTTUnsubscribeTopic(DetectEngineCtx *de_ctx, break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-quic-cyu-hash.c b/src/detect-quic-cyu-hash.c index 88197a5e38..246f36a41e 100644 --- a/src/detect-quic-cyu-hash.c +++ b/src/detect-quic-cyu-hash.c @@ -107,7 +107,7 @@ static uint8_t DetectEngineInspectQuicHash(DetectEngineCtx *de_ctx, DetectEngine break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-quic-cyu-string.c b/src/detect-quic-cyu-string.c index 9290fa4123..dfec432c20 100644 --- a/src/detect-quic-cyu-string.c +++ b/src/detect-quic-cyu-string.c @@ -105,7 +105,7 @@ static uint8_t DetectEngineInspectQuicString(DetectEngineCtx *de_ctx, break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-template-rust-buffer.c b/src/detect-template-rust-buffer.c index f1c8c97bb2..3f016f4b16 100644 --- a/src/detect-template-rust-buffer.c +++ b/src/detect-template-rust-buffer.c @@ -103,7 +103,7 @@ static uint8_t DetectEngineInspectTemplateRustBuffer(DetectEngineCtx *de_ctx, if (data != NULL) { const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)data, data_len, 0, DETECT_CI_FLAGS_SINGLE, + data, data_len, 0, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { ret = DETECT_ENGINE_INSPECT_SIG_MATCH; diff --git a/src/detect-tls-certs.c b/src/detect-tls-certs.c index 9ff185c494..7310461ea2 100644 --- a/src/detect-tls-certs.c +++ b/src/detect-tls-certs.c @@ -195,7 +195,7 @@ static uint8_t DetectEngineInspectTlsCerts(DetectEngineCtx *de_ctx, DetectEngine break; const bool match = DetectEngineContentInspection(de_ctx, det_ctx, s, engine->smd, NULL, f, - (uint8_t *)buffer->inspect, buffer->inspect_len, buffer->inspect_offset, + buffer->inspect, buffer->inspect_len, buffer->inspect_offset, DETECT_CI_FLAGS_SINGLE, DETECT_ENGINE_CONTENT_INSPECTION_MODE_STATE); if (match) { return DETECT_ENGINE_INSPECT_SIG_MATCH; -- 2.47.2