Skip to content

Commit ebce728

Browse files
ldv-altkeszybz
authored andcommitted
socket: fix use of ERRNO_IS_DISCONNECT()
Given that ERRNO_IS_DISCONNECT() also matches positive values, make sure this macro is not called with arguments that do not have errno semantics. In this case the argument passed to ERRNO_IS_DISCONNECT() is the value returned by socket_acquire_peer() which can legitimately return 1 without errno semantics, so fix this by moving ERRNO_IS_DISCONNECT() invocation to the branch where the return value is known to be negative. (cherry picked from commit d5f8890)
1 parent 24256d0 commit ebce728

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/core/socket.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2361,10 +2361,12 @@ static void socket_enter_running(Socket *s, int cfd_in) {
23612361

23622362
if (s->max_connections_per_source > 0) {
23632363
r = socket_acquire_peer(s, cfd, &p);
2364-
if (ERRNO_IS_DISCONNECT(r))
2365-
return;
2366-
if (r < 0) /* We didn't have enough resources to acquire peer information, let's fail. */
2364+
if (r < 0) {
2365+
if (ERRNO_IS_DISCONNECT(r))
2366+
return;
2367+
/* We didn't have enough resources to acquire peer information, let's fail. */
23672368
goto fail;
2369+
}
23682370
if (r > 0 && p->n_ref > s->max_connections_per_source) {
23692371
_cleanup_free_ char *t = NULL;
23702372

0 commit comments

Comments
 (0)