Skip to content

Commit d4d356c

Browse files
ldv-altbluca
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) (cherry picked from commit 920568b)
1 parent 6306373 commit d4d356c

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
@@ -3236,11 +3236,13 @@ static int bus_process_internal(sd_bus *bus, sd_bus_message **ret) {
32363236
assert_not_reached();
32373237
}
32383238

3239-
if (ERRNO_IS_DISCONNECT(r)) {
3240-
bus_enter_closing(bus);
3241-
r = 1;
3242-
} else if (r < 0)
3243-
return r;
3239+
if (r < 0) {
3240+
if (ERRNO_IS_DISCONNECT(r)) {
3241+
bus_enter_closing(bus);
3242+
r = 1;
3243+
} else
3244+
return r;
3245+
}
32443246

32453247
if (ret)
32463248
*ret = NULL;

0 commit comments

Comments
 (0)