From: Christian Göttsche Date: Mon, 14 Sep 2020 17:40:42 +0000 (+0200) Subject: socket-util: reset length argument for second getsockopt call in fd_[gs]et_rcvbuf X-Git-Tag: v247-rc1~234 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=67f5ae2d6986d0271fa6223a68fe0104957de863;p=thirdparty%2Fsystemd.git socket-util: reset length argument for second getsockopt call in fd_[gs]et_rcvbuf In case the first getsockopt() call changes the value. --- diff --git a/src/basic/socket-util.c b/src/basic/socket-util.c index a6552b26876..f2e1148e874 100644 --- a/src/basic/socket-util.c +++ b/src/basic/socket-util.c @@ -640,6 +640,7 @@ int fd_set_sndbuf(int fd, size_t n, bool increase) { /* 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) && increase ? (size_t) value >= n*2 : (size_t) value == n*2) return 1; @@ -670,6 +671,7 @@ int fd_set_rcvbuf(int fd, size_t n, bool increase) { /* 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) && increase ? (size_t) value >= n*2 : (size_t) value == n*2) return 1;