From: Yu Watanabe Date: Tue, 8 Sep 2020 15:07:50 +0000 (+0900) Subject: util: refuse to set too large value for socket buffer size X-Git-Tag: v247-rc1~278^2~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1263c85ef32ea35969748cd4304cd1a51d19e8d1;p=thirdparty%2Fsystemd.git util: refuse to set too large value for socket buffer size --- diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index fb126598578..3230d76b02b 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -621,6 +621,9 @@ int fd_inc_sndbuf(int fd, size_t n) { int r, value; socklen_t l = sizeof(value); + if (n > INT_MAX) + return -ERANGE; + r = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &l); if (r >= 0 && l == sizeof(value) && (size_t) value >= n*2) return 0; @@ -640,6 +643,9 @@ int fd_inc_rcvbuf(int fd, size_t n) { int r, value; socklen_t l = sizeof(value); + if (n > INT_MAX) + return -ERANGE; + r = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, &l); if (r >= 0 && l == sizeof(value) && (size_t) value >= n*2) return 0;