summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Göttsche <cgzones@googlemail.com>2020-09-14 19:40:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-09-20 12:11:37 +0200
commit361950e3e5ec8ee1f9262930262ac62f7a95e985 (patch)
tree39b2a342f7da416e0396d7344b1c193f3023e90f
parent5f6e511bdbadead92f243732817f5c65c4f492f4 (diff)
downloadsystemd-361950e3e5ec8ee1f9262930262ac62f7a95e985.tar.gz
socket-util: reset length argument for second getsockopt call in fd_[gs]et_rcvbuf
In case the first getsockopt() call changes the value. (cherry picked from commit 67f5ae2d6986d0271fa6223a68fe0104957de863) (cherry picked from commit 64d58480ac2e5da611d181beab22ee4b4299f522)
-rw-r--r--src/basic/socket-util.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c
index f54b8b4275..bd49c0f48a 100644
--- a/src/basic/socket-util.c
+++ b/src/basic/socket-util.c
@@ -634,6 +634,7 @@ int fd_inc_sndbuf(int fd, size_t n) {
/* SO_SNDBUF above may set to the kernel limit, instead of the requested size.
* So, we need to check the actual buffer size here. */
+ l = sizeof(value);
r = getsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, &l);
if (r >= 0 && l == sizeof(value) && (size_t) value >= n*2)
return 1;
@@ -664,6 +665,7 @@ int fd_inc_rcvbuf(int fd, size_t n) {
/* SO_RCVBUF above may set to the kernel limit, instead of the requested size.
* So, we need to check the actual buffer size here. */
+ l = sizeof(value);
r = getsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, &l);
if (r >= 0 && l == sizeof(value) && (size_t) value >= n*2)
return 1;