From 41960b421291070eca84154ffa2c0503223e1d55 Mon Sep 17 00:00:00 2001 From: cpq Date: Sun, 25 Sep 2022 11:58:28 +0100 Subject: [PATCH] Optimize fuzzer --- test/fuzz.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/fuzz.c b/test/fuzz.c index 0484bbb6..920d9220 100644 --- a/test/fuzz.c +++ b/test/fuzz.c @@ -71,10 +71,11 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { struct eth *eth = (struct eth *) pkt; memcpy(pkt, data, size); if (size > sizeof(*eth)) { - static uint8_t i; - uint16_t types[] = {0x800, 0x800, 0x806, 0x86dd}; + static size_t i; + uint16_t eth_types[] = {0x800, 0x800, 0x806, 0x86dd}; memcpy(eth->dst, ifp->mac, 6); // Set valid destination MAC - eth->type = mg_htons(types[i++ & 3]); + eth->type = mg_htons(eth_types[i++]); + if (i >= sizeof(eth_types) / sizeof(eth_types[0])) i = 0; } mip_rx(ifp, (void *) pkt, size);