From: Philippe Antoine Date: Tue, 18 Jan 2022 09:50:46 +0000 (+0100) Subject: fuzz: fix integer warnings X-Git-Tag: suricata-7.0.0-beta1~821 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=df83f7899d7459c9e2c97e8d7860896e9861a123;p=thirdparty%2Fsuricata.git fuzz: fix integer warnings Ticket: 4516 --- diff --git a/src/tests/fuzz/fuzz_applayerparserparse.c b/src/tests/fuzz/fuzz_applayerparserparse.c index cf397a72ad..1a501eb430 100644 --- a/src/tests/fuzz/fuzz_applayerparserparse.c +++ b/src/tests/fuzz/fuzz_applayerparserparse.c @@ -33,7 +33,7 @@ AppLayerParserThreadCtx *alp_tctx = NULL; const uint8_t separator[] = {0x01, 0xD5, 0xCA, 0x7A}; SCInstance surifuzz; -uint64_t forceLayer = 0; +AppProto forceLayer = 0; int LLVMFuzzerInitialize(int *argc, char ***argv) { @@ -42,14 +42,14 @@ int LLVMFuzzerInitialize(int *argc, char ***argv) AppProto applayer = StringToAppProto(target_suffix + 1); if (applayer != ALPROTO_UNKNOWN) { forceLayer = applayer; - printf("Forcing %s=%" PRIu64 "\n", AppProtoToString(forceLayer), forceLayer); + printf("Forcing %s=%" PRIu16 "\n", AppProtoToString(forceLayer), forceLayer); return 0; } } // else const char *forceLayerStr = getenv("FUZZ_APPLAYER"); if (forceLayerStr) { - if (ByteExtractStringUint64(&forceLayer, 10, 0, forceLayerStr) < 0) { + if (ByteExtractStringUint16(&forceLayer, 10, 0, forceLayerStr) < 0) { forceLayer = 0; printf("Invalid numeric value for FUZZ_APPLAYER environment variable"); } else { @@ -108,8 +108,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) f->flags |= FLOW_IPV4; f->src.addr_data32[0] = 0x01020304; f->dst.addr_data32[0] = 0x05060708; - f->sp = (data[2] << 8) | data[3]; - f->dp = (data[4] << 8) | data[5]; + f->sp = (uint16_t)((data[2] << 8) | data[3]); + f->dp = (uint16_t)((data[4] << 8) | data[5]); f->proto = data[1]; memset(&ssn, 0, sizeof(TcpSession)); f->protoctx = &ssn; diff --git a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c index b743ad3abf..7f30d459e8 100644 --- a/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c +++ b/src/tests/fuzz/fuzz_applayerprotodetectgetproto.c @@ -50,7 +50,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) alpd_tctx = AppLayerProtoDetectGetCtxThread(); } - f = TestHelperBuildFlow(AF_INET, "1.2.3.4", "5.6.7.8", (data[2] << 8) | data[3], (data[4] << 8) | data[5]); + f = TestHelperBuildFlow(AF_INET, "1.2.3.4", "5.6.7.8", (uint16_t)((data[2] << 8) | data[3]), + (uint16_t)((data[4] << 8) | data[5])); if (f == NULL) { return 0; }