]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check for empty packets
authorAlan T. DeKok <aland@freeradius.org>
Sun, 17 Jan 2021 15:12:05 +0000 (10:12 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sun, 17 Jan 2021 15:12:05 +0000 (10:12 -0500)
src/protocols/dhcpv6/base.c

index 1871c7f56d89e90a8e5f728e81af4e52a99d59d5..ed5b4a35fbd2068b76f6b1df44f8045f814fa2c8 100644 (file)
@@ -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.
         */