]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
clamp values
authorAlan T. DeKok <aland@freeradius.org>
Fri, 6 Dec 2024 15:15:49 +0000 (10:15 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Sat, 7 Dec 2024 14:36:47 +0000 (09:36 -0500)
src/lib/bio/fd_open.c

index c9ec70f70cf00f6aa184b9a0a93220351986d7db..e6f88522c46aec716bf9a338f5802e97e7599f0a 100644 (file)
@@ -106,10 +106,16 @@ static int fr_bio_fd_common_datagram(int fd, UNUSED fr_socket_t const *sock, fr_
        }
 #endif
 
+
 #ifdef SO_RCVBUF
        if (cfg->recv_buff) {
                int opt = cfg->recv_buff;
 
+               /*
+                *      Clamp value to something reasonable.
+                */
+               if (opt > (1 << 29)) opt = (1 << 29);
+
                if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &opt, sizeof(opt)) < 0) {
                        fr_strerror_printf("Failed setting SO_RCVBUF: %s", fr_syserror(errno));
                        return -1;
@@ -121,6 +127,11 @@ static int fr_bio_fd_common_datagram(int fd, UNUSED fr_socket_t const *sock, fr_
        if (cfg->send_buff) {
                int opt = cfg->send_buff;
 
+               /*
+                *      Clamp value to something reasonable.
+                */
+               if (opt > (1 << 29)) opt = (1 << 29);
+
                if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &opt, sizeof(opt)) < 0) {
                        fr_strerror_printf("Failed setting SO_SNDBUF: %s", fr_syserror(errno));
                        return -1;