]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Tweak mod_read() range check on packet code (CID #1419883?)
authorJames Jones <jejones3141@gmail.com>
Tue, 7 Nov 2023 18:54:54 +0000 (12:54 -0600)
committerAlan DeKok <aland@freeradius.org>
Thu, 18 Jan 2024 14:36:33 +0000 (09:36 -0500)
buffer[0] is used as index into fr_radius_packet_names[], so
allowing FR_PACKET_CODE_MAX will fall off the end. This may
placate coverity, but I believe it is needed in any case.

src/listen/radius/proto_radius_tcp.c

index e228824f53267374356add8956cbcf236fc62741..46f0157147011c059d5ca40c80ac799883c7681e 100644 (file)
@@ -134,7 +134,7 @@ static ssize_t mod_read(fr_listen_t *li, UNUSED void **packet_ctx, fr_time_t *re
        /*
         *      We MUST always start with a known RADIUS packet.
         */
-       if ((buffer[0] == 0) || (buffer[0] > FR_RADIUS_CODE_MAX)) {
+       if ((buffer[0] == 0) || (buffer[0] >= FR_RADIUS_CODE_MAX)) {
                DEBUG("proto_radius_tcp got invalid packet code %d", buffer[0]);
                thread->stats.total_unknown_types++;
                return -1;