Skip to content

Commit

Permalink
sd-bus: fix use of ERRNO_IS_DISCONNECT()
Browse files Browse the repository at this point in the history
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 bus_socket_process_watch_bind(), bus_socket_process_opening(),
and bus_socket_process_authenticating() which can legitimately return
positive values without errno semantics, so fix this by moving the
ERRNO_IS_DISCONNECT() invocation to the branch where the return value
is known to be negative.
  • Loading branch information
ldv-alt committed Jul 16, 2023
1 parent d5f8890 commit bb228f0
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/libsystemd/sd-bus/sd-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -3284,11 +3284,13 @@ static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
assert_not_reached();
}

if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
r = 1;
} else if (r < 0)
return r;
if (r < 0) {
if (ERRNO_IS_DISCONNECT(r)) {
bus_enter_closing(bus);
r = 1;
} else
return r;
}

if (ret)
*ret = NULL;
Expand Down

0 comments on commit bb228f0

Please sign in to comment.