From: Philippe Antoine Date: Mon, 29 Jul 2024 19:50:36 +0000 (+0200) Subject: log: fix -Wshorten-64-to-32 warnings X-Git-Tag: suricata-8.0.0-beta1~967 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4ae57997208b4da188118a94ef342849e5fdeba9;p=thirdparty%2Fsuricata.git log: fix -Wshorten-64-to-32 warnings Ticket: #6186 --- diff --git a/src/log-cf-common.c b/src/log-cf-common.c index 077813501c..43fc9e3a9d 100644 --- a/src/log-cf-common.c +++ b/src/log-cf-common.c @@ -123,7 +123,7 @@ int LogCustomFormatParse(LogCustomFormat *cf, const char *format) n = LOG_NODE_STRLEN-2; np = NULL; /* End */ }else{ - n = np-p; + n = (uint32_t)(np - p); } strlcpy(node->data,p,n+1); p = np; @@ -151,7 +151,7 @@ int LogCustomFormatParse(LogCustomFormat *cf, const char *format) np = strchr(p, '}'); if (np != NULL && np-p > 1 && np-p < LOG_NODE_STRLEN-2) { p++; - n = np-p; + n = (uint32_t)(np - p); strlcpy(node->data, p, n+1); p = np; } else { diff --git a/src/log-httplog.c b/src/log-httplog.c index 93b6e0da91..ee561f5609 100644 --- a/src/log-httplog.c +++ b/src/log-httplog.c @@ -130,7 +130,7 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const SCTime_t { LogHttpFileCtx *httplog_ctx = aft->httplog_ctx; uint32_t i; - uint32_t datalen; + size_t datalen; char buf[128]; uint8_t *cvalue = NULL; @@ -251,9 +251,9 @@ static void LogHttpLogCustom(LogHttpLogThread *aft, htp_tx_t *tx, const SCTime_t if (tx->request_headers != NULL) { h_request_hdr = htp_table_get_c(tx->request_headers, "Cookie"); if (h_request_hdr != NULL) { - cvalue_len = GetCookieValue((uint8_t *) bstr_ptr(h_request_hdr->value), - bstr_len(h_request_hdr->value), (char *) node->data, - &cvalue); + cvalue_len = GetCookieValue((uint8_t *)bstr_ptr(h_request_hdr->value), + (uint32_t)bstr_len(h_request_hdr->value), (char *)node->data, + &cvalue); } } if (cvalue_len > 0 && cvalue != NULL) { diff --git a/src/log-pcap.c b/src/log-pcap.c index c0b6ef7d00..253560961d 100644 --- a/src/log-pcap.c +++ b/src/log-pcap.c @@ -1466,7 +1466,7 @@ static OutputInitResult PcapLogInitCtx(ConfNode *conf) } else { lvl = 0; } - comp->lz4f_prefs.compressionLevel = lvl; + comp->lz4f_prefs.compressionLevel = (int)lvl; /* Allocate resources for lz4. */ diff --git a/src/log-tlslog.c b/src/log-tlslog.c index db886f7b13..12e235c21a 100644 --- a/src/log-tlslog.c +++ b/src/log-tlslog.c @@ -91,9 +91,8 @@ typedef struct LogTlsLogThread_ { MemBuffer *buffer; } LogTlsLogThread; -int TLSGetIPInformations(const Packet *p, char* srcip, size_t srcip_len, - Port* sp, char* dstip, size_t dstip_len, Port* dp, - int ipproto) +int TLSGetIPInformations(const Packet *p, char *srcip, socklen_t srcip_len, Port *sp, char *dstip, + socklen_t dstip_len, Port *dp, int ipproto) { if ((PKT_IS_TOSERVER(p))) { switch (ipproto) { diff --git a/src/log-tlslog.h b/src/log-tlslog.h index fb01562842..4a224ff156 100644 --- a/src/log-tlslog.h +++ b/src/log-tlslog.h @@ -27,8 +27,7 @@ void LogTlsLogRegister(void); -int TLSGetIPInformations(const Packet *p, char* srcip, size_t srcip_len, - Port* sp, char* dstip, size_t dstip_len, - Port* dp, int ipproto); +int TLSGetIPInformations(const Packet *p, char *srcip, socklen_t srcip_len, Port *sp, char *dstip, + socklen_t dstip_len, Port *dp, int ipproto); #endif /* SURICATA_LOG_TLSLOG_H */ diff --git a/src/util-print.c b/src/util-print.c index 65de27eb38..16b66679f6 100644 --- a/src/util-print.c +++ b/src/util-print.c @@ -90,10 +90,9 @@ void PrintRawUriFp(FILE *fp, uint8_t *buf, uint32_t buflen) fprintf(fp, "%s", nbuf); } -void PrintRawUriBuf(char *retbuf, uint32_t *offset, uint32_t retbuflen, - uint8_t *buf, uint32_t buflen) +void PrintRawUriBuf(char *retbuf, uint32_t *offset, uint32_t retbuflen, uint8_t *buf, size_t buflen) { - for (uint32_t u = 0; u < buflen; u++) { + for (size_t u = 0; u < buflen; u++) { if (isprint(buf[u]) && buf[u] != '\"') { if (buf[u] == '\\') { PrintBufferData(retbuf, offset, retbuflen, diff --git a/src/util-print.h b/src/util-print.h index e33de78199..c9f19b4cdb 100644 --- a/src/util-print.h +++ b/src/util-print.h @@ -41,7 +41,7 @@ void PrintBufferRawLineHex(char *, int *,int, const uint8_t *, uint32_t); void PrintRawUriFp(FILE *, uint8_t *, uint32_t); -void PrintRawUriBuf(char *, uint32_t *, uint32_t, uint8_t *, uint32_t); +void PrintRawUriBuf(char *, uint32_t *, uint32_t, uint8_t *, size_t); void PrintRawDataFp(FILE *, const uint8_t *, uint32_t); void PrintRawDataToBuffer(uint8_t *dst_buf, uint32_t *dst_buf_offset_ptr, uint32_t dst_buf_size, const uint8_t *src_buf, uint32_t src_buf_len);