]> 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)
committerJason Ish <jason.ish@oisf.net>
Sat, 9 Jul 2022 15:09:57 +0000 (09:09 -0600)
Ticket: 4516

(cherry picked from commit e3180e3248e38311ad56a080233ad1a8d31a623b)

src/output-json-dnp3.c
src/output-json-file.c
src/output-json-ftp.c
src/output-json-stats.c

index 7b2a7192e4e87d8d688816319048c54e2a4a4117..5ed7b5cd99989bf4b5eb20080a7c66e70274c9b3 100644 (file)
@@ -207,7 +207,7 @@ void JsonDNP3LogResponse(JsonBuilder *js, DNP3Transaction *dnp3tx)
     jb_close(js);
 
     jb_open_object(js, "iin");
-    JsonDNP3LogIin(js, dnp3tx->response_iin.iin1 << 8 | dnp3tx->response_iin.iin2);
+    JsonDNP3LogIin(js, (uint16_t)(dnp3tx->response_iin.iin1 << 8 | dnp3tx->response_iin.iin2));
     jb_close(js);
 }
 
index 5932c6ab8f245de188684ec5eed6434d01d7292f..5771b1bb6928a07e90b598b34507850d7fb2ed17 100644 (file)
@@ -203,7 +203,7 @@ JsonBuilder *JsonBuildFileInfoRecord(const Packet *p, const File *ff,
  *  \brief Write meta data on a single line json record
  */
 static void FileWriteJsonRecord(JsonFileLogThread *aft, const Packet *p,
-                                const File *ff, uint32_t dir)
+                                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 fc24e8e095422998d2ae43003526c5a29a762c63..61059a03a28efeb618d3a4cf5096484348af55fd 100644 (file)
@@ -94,11 +94,16 @@ static void EveFTPLogCommand(Flow *f, FTPTransaction *tx, JsonBuilder *jb)
         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 (!reply_truncated && response->truncated) {
                 reply_truncated = true;
             }
+            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 6e82745eb7588d168d3808a114675f485d1dbd54..a46f91af6f62cd49ca722c40a7d472956924b6a8 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_ {