From: Alan T. DeKok Date: Fri, 6 Dec 2024 15:15:49 +0000 (-0500) Subject: clamp values X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bd9f459c5035fb8aefb33e0f5e4a6458615747bd;p=thirdparty%2Ffreeradius-server.git clamp values --- diff --git a/src/lib/bio/fd_open.c b/src/lib/bio/fd_open.c index c9ec70f70cf..e6f88522c46 100644 --- a/src/lib/bio/fd_open.c +++ b/src/lib/bio/fd_open.c @@ -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;