]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
check corner cases
authorAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 14:16:09 +0000 (10:16 -0400)
committerAlan T. DeKok <aland@freeradius.org>
Thu, 7 Aug 2025 15:01:23 +0000 (11:01 -0400)
we can't starve threads of ports :(

src/modules/rlm_radius/rlm_radius.c

index 6c92b7fc004e089ac3397108afc99c233e63c03b..d687ad0671d389011bedf5469a206df2443bb2d9 100644 (file)
@@ -713,15 +713,26 @@ check_others:
                        return -1;
                }
 
-#ifdef REUSE_CONN
                /*
                 *      If there is a limited source port range, then set the reuse port flag.  This lets us
                 *      bind multiple sockets to the same port before we connect() them.
                 */
                if ((inst->fd_config.src_port_start > 0) && (inst->fd_config.src_port_end > 0)) {
+                       if (inst->fd_config.src_port_end <= inst->fd_config.src_port_start) {
+                               cf_log_perr(conf, "src_port_start must be smaller than src_port_end");
+                               return -1;
+                       }
+
+                       if ((inst->fd_config.src_port_end - inst->fd_config.src_port_start) < (int) main_config->max_workers) {
+                               cf_log_perr(conf, "src_port_start / end range is not enough for %u worker threads",
+                                           main_config->max_workers);
+                               return -1;
+                       }
+
+#ifdef REUSE_CONN
                        inst->fd_config.reuse_port = 1;
-               }
 #endif
+               }
        }
 
        if (fr_bio_fd_check_config(&inst->fd_config) < 0) {