From 0f3da640de23f59b215af143dbffdf570fb4662d Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Mon, 22 Jan 2018 09:55:38 +0900 Subject: [PATCH] fuzz: check return value Closes CID #1385306 and #1385300. --- src/fuzz/fuzz-dns-packet.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/fuzz/fuzz-dns-packet.c b/src/fuzz/fuzz-dns-packet.c index 3d8d79a..0f25081 100644 --- a/src/fuzz/fuzz-dns-packet.c +++ b/src/fuzz/fuzz-dns-packet.c @@ -21,23 +21,20 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { _cleanup_(dns_packet_unrefp) DnsPacket *p = NULL; - int r; if (size > DNS_PACKET_SIZE_MAX) return 0; - r = dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX); - if (r < 0) - return 0; + assert_se(dns_packet_new(&p, DNS_PROTOCOL_DNS, 0, DNS_PACKET_SIZE_MAX) >= 0); p->size = 0; /* by default append starts after the header, undo that */ - dns_packet_append_blob(p, data, size, NULL); + assert_se(dns_packet_append_blob(p, data, size, NULL) >= 0); if (size < DNS_PACKET_HEADER_SIZE) { /* make sure we pad the packet back up to the minimum header size */ - assert(p->allocated >= DNS_PACKET_HEADER_SIZE); + assert_se(p->allocated >= DNS_PACKET_HEADER_SIZE); memzero(DNS_PACKET_DATA(p) + size, DNS_PACKET_HEADER_SIZE - size); p->size = DNS_PACKET_HEADER_SIZE; } - dns_packet_extract(p); + (void) dns_packet_extract(p); return 0; } -- 2.7.4