From: Philippe Antoine Date: Tue, 18 Jan 2022 09:56:48 +0000 (+0100) Subject: output: fix integer warnings X-Git-Tag: suricata-5.0.9~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=08b2ffa4344fed7be245dc32d596702a414ff15f;p=thirdparty%2Fsuricata.git output: fix integer warnings Ticket: 4516 (cherry picked from commit e3180e3248e38311ad56a080233ad1a8d31a623b) --- diff --git a/src/app-layer-ftp.h b/src/app-layer-ftp.h index 7c8bab2d0b..c5ccab6e16 100644 --- a/src/app-layer-ftp.h +++ b/src/app-layer-ftp.h @@ -125,7 +125,7 @@ typedef struct FtpLineState_ { typedef struct FTPString_ { uint8_t *str; - uint16_t len; + uint32_t len; TAILQ_ENTRY(FTPString_) next; } FTPString; diff --git a/src/output-json-dnp3.c b/src/output-json-dnp3.c index b24320f36a..a1d20bda2b 100644 --- a/src/output-json-dnp3.c +++ b/src/output-json-dnp3.c @@ -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); } diff --git a/src/output-json-file.c b/src/output-json-file.c index 3ff42454cb..5f971e3fee 100644 --- a/src/output-json-file.c +++ b/src/output-json-file.c @@ -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;; diff --git a/src/output-json-ftp.c b/src/output-json-ftp.c index cd34ed61aa..1f8933166a 100644 --- a/src/output-json-ftp.c +++ b/src/output-json-ftp.c @@ -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 */ diff --git a/src/output-json-stats.c b/src/output-json-stats.c index 666ec1763b..4ac46cbcdb 100644 --- a/src/output-json-stats.c +++ b/src/output-json-stats.c @@ -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_ {