Skip to content

Commit 920568b

Browse files
ldv-altkeszybz
authored andcommitted
sd-bus: 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 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. (cherry picked from commit bb228f0)
1 parent ebce728 commit 920568b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/libsystemd/sd-bus/sd-bus.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3249,11 +3249,13 @@ static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
32493249
assert_not_reached();
32503250
}
32513251

3252-
if (ERRNO_IS_DISCONNECT(r)) {
3253-
bus_enter_closing(bus);
3254-
r = 1;
3255-
} else if (r < 0)
3256-
return r;
3252+
if (r < 0) {
3253+
if (ERRNO_IS_DISCONNECT(r)) {
3254+
bus_enter_closing(bus);
3255+
r = 1;
3256+
} else
3257+
return r;
3258+
}
32573259

32583260
if (ret)
32593261
*ret = NULL;

0 commit comments

Comments
 (0)