]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
fixed overflow
authorCatalina Pineros <catalina.pineros@inkbridge.io>
Mon, 16 Mar 2026 20:03:02 +0000 (16:03 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Mon, 16 Mar 2026 22:26:02 +0000 (18:26 -0400)
if there is KEY_SLOTS, the valid range is [0, KEY_SLOTS - 1], and key KEY_SLOTS should be outside of redis lot range

src/lib/redis/cluster.c

index a2f77a4a2dd377a9b21158bfcf2757c7578a8812..24ecbd15a504866791d761ef956b7b571f5eca53 100644 (file)
@@ -470,7 +470,7 @@ static fr_redis_cluster_rcode_t cluster_node_conf_from_redirect(uint16_t *key_sl
        }
        p = q;
        key = strtoul(p, &q, 10);
-       if (key > KEY_SLOTS) {
+       if (key >= KEY_SLOTS) {
                fr_strerror_printf("Key %lu outside of redis slot range", key);
                return FR_REDIS_CLUSTER_RCODE_BAD_INPUT;
        }
@@ -939,8 +939,8 @@ static fr_redis_cluster_rcode_t cluster_map_get(redisReply **out, fr_redis_conn_
                        goto error;
                }
 
-               if (map->element[0]->integer > KEY_SLOTS) {
-                       fr_strerror_printf("Cluster map %zu key slot start is too high, expected <= "
+               if (map->element[0]->integer >= KEY_SLOTS) {
+                       fr_strerror_printf("Cluster map %zu key slot start is too high, expected < "
                                           STRINGIFY(KEY_SLOTS) " got %lli", i, map->element[0]->integer);
                        goto error;
                }
@@ -960,8 +960,8 @@ static fr_redis_cluster_rcode_t cluster_map_get(redisReply **out, fr_redis_conn_
                        goto error;
                }
 
-               if (map->element[1]->integer > KEY_SLOTS) {
-                       fr_strerror_printf("Cluster map %zu key slot end is too high, expected <= "
+               if (map->element[1]->integer >= KEY_SLOTS) {
+                       fr_strerror_printf("Cluster map %zu key slot end is too high, expected < "
                                           STRINGIFY(KEY_SLOTS) " got %lli", i, map->element[1]->integer);
                        goto error;
                }