From: Alan T. DeKok Date: Sun, 17 Jan 2021 15:12:05 +0000 (-0500) Subject: check for empty packets X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=24a9d80a87641ffac2193c0e0550206ceb95455a;p=thirdparty%2Ffreeradius-server.git check for empty packets --- diff --git a/src/protocols/dhcpv6/base.c b/src/protocols/dhcpv6/base.c index 1871c7f56d8..ed5b4a35fbd 100644 --- a/src/protocols/dhcpv6/base.c +++ b/src/protocols/dhcpv6/base.c @@ -229,6 +229,11 @@ static ssize_t fr_dhcpv6_ok_internal(uint8_t const *packet, uint8_t const *end, bool allow_relay; size_t packet_len = end - packet; + if (end == packet) { + fr_strerror_const("Packet is empty"); + return 0; + } + if (depth > DHCPV6_MAX_RELAY_NESTING) { fr_strerror_const("Too many layers forwarded packets"); return 0; @@ -632,6 +637,8 @@ ssize_t fr_dhcpv6_decode(TALLOC_CTX *ctx, uint8_t const *packet, size_t packet_l fr_dhcpv6_decode_ctx_t packet_ctx; fr_pair_t *vp; + if (!packet_len) return 0; /* protect access to packet[0] */ + /* * Get the packet type. */