From 4085cf44dbe0ce108e3af6612860a1f88ca83148 Mon Sep 17 00:00:00 2001 From: Philippe Antoine Date: Wed, 14 May 2025 21:15:41 +0200 Subject: [PATCH] detect: fix some -Wshorten-64-to-32 warnings Ticket: #6186 --- src/detect-engine.c | 5 +++-- src/detect-ftp-reply.c | 2 +- src/detect-http-header.c | 8 ++++---- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/detect-engine.c b/src/detect-engine.c index 5117c38203..eec091f566 100644 --- a/src/detect-engine.c +++ b/src/detect-engine.c @@ -3487,9 +3487,10 @@ static uint32_t DetectKeywordCtxHashFunc(HashListTable *ht, void *data, uint16_t { DetectEngineThreadKeywordCtxItem *ctx = data; const char *name = ctx->name; - uint64_t hash = StringHashDjb2((const uint8_t *)name, strlen(name)) + (ptrdiff_t)ctx->data; + uint64_t hash = + StringHashDjb2((const uint8_t *)name, (uint32_t)strlen(name)) + (ptrdiff_t)ctx->data; hash %= ht->array_size; - return hash; + return (uint32_t)hash; } static char DetectKeywordCtxCompareFunc(void *data1, uint16_t len1, void *data2, uint16_t len2) diff --git a/src/detect-ftp-reply.c b/src/detect-ftp-reply.c index 1173801a4c..be2e9cfad5 100644 --- a/src/detect-ftp-reply.c +++ b/src/detect-ftp-reply.c @@ -75,7 +75,7 @@ static bool DetectFTPReplyGetData(DetectEngineThreadCtx *_det_ctx, const void *t DEBUG_VALIDATE_BUG_ON(wrapper->response == NULL); if (index == count) { *buffer = (const uint8_t *)wrapper->response->response; - *buffer_len = wrapper->response->length; + *buffer_len = (uint32_t)wrapper->response->length; return true; } count++; diff --git a/src/detect-http-header.c b/src/detect-http-header.c index cef3f0d260..ff25be91fc 100644 --- a/src/detect-http-header.c +++ b/src/detect-http-header.c @@ -462,7 +462,7 @@ static int g_response_header_thread_id = 0; typedef struct HttpMultiBufItem { uint8_t *buffer; - size_t len; + uint32_t len; } HttpMultiBufItem; typedef struct HttpMultiBufHeaderThreadData { @@ -539,9 +539,9 @@ static bool GetHttp1HeaderData(DetectEngineThreadCtx *det_ctx, const void *txv, } for (size_t i = 0; i < no_of_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; + uint32_t size1 = (uint32_t)htp_header_name_len(h); + uint32_t size2 = (uint32_t)htp_header_value_len(h); + uint32_t size = size1 + size2 + 2; if (hdr_td->items[i].len < size) { // Use realloc, as this pointer is not freed until HttpMultiBufHeaderThreadDataFree void *tmp = SCRealloc(hdr_td->items[i].buffer, size);