From e8b0324f8165fdf878ec969db1c57f2667aeda20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Thu, 6 Apr 2023 15:58:46 +0200 Subject: [PATCH] test/fuzz: Don't crash with assertion failure when a packet is too big A fuzzer may generate big packets, and it will interpret assertion failures as bugs. Instead of asserting that the packet size is reasonable, simply skip the packet when it's not the case. --- test/fuzz/fuzz_common.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/test/fuzz/fuzz_common.c b/test/fuzz/fuzz_common.c index c4dcfcec..e8ed4329 100644 --- a/test/fuzz/fuzz_common.c +++ b/test/fuzz/fuzz_common.c @@ -192,7 +192,11 @@ static void input_pkt(struct netif *netif, const u8_t *data, size_t len) struct pbuf *p, *q; err_t err; - LWIP_ASSERT("pkt too big", len <= 0xFFFF); + if (len > 0xFFFF) { + printf("pkt too big (%#zX bytes)\n", len); + return; + } + p = pbuf_alloc(PBUF_RAW, (u16_t)len, PBUF_POOL); LWIP_ASSERT("alloc failed", p); for(q = p; q != NULL; q = q->next) {