mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 16:37:19 +09:00
util: refuse to set too large value for socket buffer size
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user