]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
detect: fix some -Wshorten-64-to-32 warnings
authorPhilippe Antoine <pantoine@oisf.net>
Wed, 14 May 2025 19:15:41 +0000 (21:15 +0200)
committerVictor Julien <victor@inliniac.net>
Fri, 16 May 2025 19:33:52 +0000 (21:33 +0200)
Ticket: #6186

src/detect-engine.c
src/detect-ftp-reply.c
src/detect-http-header.c

index 5117c382033ed6759c591ac771c799a37a72b738..eec091f56674ebafcdb78248d00373652a3b6fa9 100644 (file)
@@ -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)
index 1173801a4ca4f61a6160150a40640c6e1f364f20..be2e9cfad506c459fcec0df08cd90bd16ebe5976 100644 (file)
@@ -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++;
index cef3f0d260a892c39d32867db2a897eefa34963b..ff25be91fc5e1354f5f4b9af7752fae4fc24088f 100644 (file)
@@ -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);