]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
output: fix integer warnings
authorPhilippe Antoine <contact@catenacyber.fr>
Tue, 18 Jan 2022 09:56:48 +0000 (10:56 +0100)
committerVictor Julien <vjulien@oisf.net>
Tue, 19 Apr 2022 18:53:40 +0000 (20:53 +0200)
Ticket: 4516
(cherry picked from commit e3180e3248e38311ad56a080233ad1a8d31a623b)

src/app-layer-ftp.h
src/output-json-dnp3.c
src/output-json-file.c
src/output-json-ftp.c
src/output-json-stats.c

index 7c8bab2d0bba1edf543583519d86025c058cac86..c5ccab6e16d0d1b610250325d8b75ba40cb62050 100644 (file)
@@ -125,7 +125,7 @@ typedef struct FtpLineState_ {
 
 typedef struct FTPString_ {
     uint8_t *str;
-    uint16_t len;
+    uint32_t len;
     TAILQ_ENTRY(FTPString_) next;
 } FTPString;
 
index b24320f36a61c7bba56c8cefc72f90033e66210d..a1d20bda2b09492dcd0fa76886bbdb883f2260d2 100644 (file)
@@ -278,8 +278,7 @@ json_t *JsonDNP3LogResponse(DNP3Transaction *dnp3tx)
     json_object_set_new(al, "function_code",
         json_integer(dnp3tx->response_ah.function_code));
 
-    json_t *iinjs = JsonDNP3LogIin(dnp3tx->response_iin.iin1 << 8 |
-        dnp3tx->response_iin.iin2);
+    json_t *iinjs = JsonDNP3LogIin((uint16_t)(dnp3tx->response_iin.iin1 << 8 | dnp3tx->response_iin.iin2));
     if (iinjs != NULL) {
         json_object_set_new(dnp3js, "iin", iinjs);
     }
index 3ff42454cb00475536e4d04fa4c48df05fad65aa..5f971e3feeb94f13998e1878371087bcdbb61274 100644 (file)
@@ -252,8 +252,8 @@ json_t *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
  *  \internal
  *  \brief Write meta data on a single line json record
  */
-static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p,
-                                const File *ff, uint32_t dir)
+static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p, const File *ff,
+        uint8_t dir)
 {
     HttpXFFCfg *xff_cfg = aft->filelog_ctx->xff_cfg != NULL ?
         aft->filelog_ctx->xff_cfg : aft->filelog_ctx->parent_xff_cfg;;
index cd34ed61aa4bcd45c6a988d07a5e0d5ef6a50e5d..1f8933166aa9693ec4d9f4b54d176f4140b6ab5d 100644 (file)
@@ -99,8 +99,13 @@ static json_t *JsonFTPLogCommand(Flow *f, FTPTransaction *tx)
         TAILQ_FOREACH(response, &tx->response_list, next) {
             /* handle multiple lines within the response, \r\n delimited */
             uint8_t *where = response->str;
-            uint16_t length = response->len ? response->len -1 : 0;
+            uint16_t length = 0;
             uint16_t pos;
+            if (response->len > 0 && response->len <= UINT16_MAX) {
+                length = (uint16_t)response->len - 1;
+            } else if (response->len > UINT16_MAX) {
+                length = UINT16_MAX;
+            }
             while ((pos = JsonGetNextLineFromBuffer((const char *)where, length)) != UINT16_MAX) {
                 uint16_t offset = 0;
                 /* Try to find a completion code for this line */
index 666ec1763b048177015baa858fce280e4f183bd5..4ac46cbcdb5feea791caad421509882322641894 100644 (file)
@@ -65,7 +65,7 @@ typedef enum OutputEngineInfo_ {
 
 typedef struct OutputStatsCtx_ {
     LogFileCtx *file_ctx;
-    uint32_t flags; /** Store mode */
+    uint8_t flags; /** Store mode */
 } OutputStatsCtx;
 
 typedef struct JsonStatsLogThread_ {