fuzz: fix integer warnings

Ticket: 4516
pull/7112/head
Philippe Antoine 4 years ago committed by Victor Julien
parent 5790280c95
commit df83f7899d

@ -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;

@ -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;
}

Loading…
Cancel
Save