From 5b47db7c5e133a799389760d37a4d3fa24c07c14 Mon Sep 17 00:00:00 2001 From: Quentin Young Date: Sat, 11 Jan 2020 15:16:21 -0500 Subject: [PATCH] fix memleak in libfuzzer entrypoint --- bgpd/bgp_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index 0284086ddd..be946cde04 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -494,8 +494,9 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) * BGP message is correct, and this check is performed by the i/o code, * so we need to make sure that remains true for fuzzed input. * */ - if (!validate_header(p)) - return 0; + if (!validate_header(p)) { + goto done; + } int result = 0; unsigned char pktbuf[BGP_MAX_PACKET_SIZE]; @@ -517,6 +518,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) result = bgp_process_packet(&t); } +done: peer_delete(p); FuzzingPeer = NULL; -- 2.39.5