From: Philippe Antoine Date: Thu, 22 May 2025 15:41:36 +0000 (+0200) Subject: fuzz: fix -Wshorten-64-to-32 warnings X-Git-Tag: suricata-8.0.0-rc1~85 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f6856eac9cd19c84208e5c5d41b8ae31d85f6667;p=thirdparty%2Fsuricata.git fuzz: fix -Wshorten-64-to-32 warnings Ticket: #6186 --- diff --git a/src/tests/fuzz/fuzz_applayerparserparse.c b/src/tests/fuzz/fuzz_applayerparserparse.c index 95a7d58969..4747214c07 100644 --- a/src/tests/fuzz/fuzz_applayerparserparse.c +++ b/src/tests/fuzz/fuzz_applayerparserparse.c @@ -150,7 +150,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) goto bail; } memcpy(isolatedBuffer, albuffer, alnext - albuffer); - (void) AppLayerParserParse(NULL, alp_tctx, f, f->alproto, flags, isolatedBuffer, alnext - albuffer); + (void)AppLayerParserParse(NULL, alp_tctx, f, f->alproto, flags, isolatedBuffer, + (uint32_t)(alnext - albuffer)); free(isolatedBuffer); if (FlowChangeProto(f)) { // exits if a protocol change is requested @@ -194,7 +195,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) goto bail; } memcpy(isolatedBuffer, albuffer, alsize); - (void) AppLayerParserParse(NULL, alp_tctx, f, f->alproto, flags, isolatedBuffer, alsize); + (void)AppLayerParserParse( + NULL, alp_tctx, f, f->alproto, flags, isolatedBuffer, (uint32_t)alsize); free(isolatedBuffer); } diff --git a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c index 7233c61ad9..3f4efa2de6 100644 --- a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c +++ b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c @@ -61,8 +61,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) if (data[0] & STREAM_TOSERVER) { flags = STREAM_TOSERVER; } - AppLayerProtoDetectGetProto( - alpd_tctx, f, data + HEADER_LEN, size - HEADER_LEN, f->proto, flags, &reverse); + AppLayerProtoDetectGetProto(alpd_tctx, f, data + HEADER_LEN, (uint32_t)(size - HEADER_LEN), + f->proto, flags, &reverse); FlowFree(f); return 0; diff --git a/src/tests/fuzz/fuzz_decodebase64.c b/src/tests/fuzz/fuzz_decodebase64.c index 6bbe65f7af..6610a33481 100644 --- a/src/tests/fuzz/fuzz_decodebase64.c +++ b/src/tests/fuzz/fuzz_decodebase64.c @@ -16,7 +16,7 @@ static int initialized = 0; static void Base64FuzzTest(const uint8_t *src, size_t len) { - uint32_t decoded_len = SCBase64DecodeBufferSize(len); + uint32_t decoded_len = SCBase64DecodeBufferSize((uint32_t)len); uint8_t *decoded = SCCalloc(decoded_len, sizeof(uint8_t)); for (uint8_t mode = SCBase64ModeRFC2045; mode <= SCBase64ModeStrict; mode++) { diff --git a/src/tests/fuzz/fuzz_mimedecparseline.c b/src/tests/fuzz/fuzz_mimedecparseline.c index 9331c65693..eece6c36e8 100644 --- a/src/tests/fuzz/fuzz_mimedecparseline.c +++ b/src/tests/fuzz/fuzz_mimedecparseline.c @@ -33,10 +33,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) uint8_t * next = memchr(buffer, '\n', size); if (next == NULL) { if (SCMimeSmtpGetState(state) >= MimeSmtpBody) - (void)SCSmtpMimeParseLine(buffer, size, 0, &events, state); + (void)SCSmtpMimeParseLine(buffer, (uint32_t)size, 0, &events, state); break; } else { - (void)SCSmtpMimeParseLine(buffer, next - buffer, 1, &events, state); + (void)SCSmtpMimeParseLine(buffer, (uint32_t)(next - buffer), 1, &events, state); if (buffer + size < next + 1) { break; }