summaryrefslogtreecommitdiff
path: root/src/basic/socket-util.c
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2020-09-09 00:07:50 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2020-09-09 06:39:05 +0900
commit1263c85ef32ea35969748cd4304cd1a51d19e8d1 (patch)
tree5d20e2d5678bae4423d91213d553a9b58d617cbe /src/basic/socket-util.c
parent8c63924c8d1eeb5a173669b8b06230bfe721f139 (diff)
downloadsystemd-1263c85ef32ea35969748cd4304cd1a51d19e8d1.tar.gz
util: refuse to set too large value for socket buffer size
Diffstat (limited to 'src/basic/socket-util.c')
-rw-r--r--src/basic/socket-util.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index fb12659857..3230d76b02 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;