Skip to content
This repository was archived by the owner on Aug 6, 2020. It is now read-only.

Commit 6d586a1

Browse files
poetteringkeszybz
authored andcommitted
sd-bus: if we receive an invalid dbus message, ignore and proceeed
dbus-daemon might have a slightly different idea of what a valid msg is than us (for example regarding valid msg and field sizes). Let's hence try to proceed if we can and thus drop messages rather than fail the connection if we fail to validate a message. Hopefully the differences in what is considered valid are not visible for real-life usecases, but are specific to exploit attempts only.
1 parent dc9cced commit 6d586a1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,7 +1072,7 @@ static int bus_socket_read_message_need(sd_bus *bus, size_t *need) {
10721072
}
10731073

10741074
static int bus_socket_make_message(sd_bus *bus, size_t size) {
1075-
sd_bus_message *t;
1075+
sd_bus_message *t = NULL;
10761076
void *b;
10771077
int r;
10781078

@@ -1097,7 +1097,9 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) {
10971097
bus->fds, bus->n_fds,
10981098
NULL,
10991099
&t);
1100-
if (r < 0) {
1100+
if (r == -EBADMSG)
1101+
log_debug_errno(r, "Received invalid message from connection %s, dropping.", strna(bus->description));
1102+
else if (r < 0) {
11011103
free(b);
11021104
return r;
11031105
}
@@ -1108,7 +1110,8 @@ static int bus_socket_make_message(sd_bus *bus, size_t size) {
11081110
bus->fds = NULL;
11091111
bus->n_fds = 0;
11101112

1111-
bus->rqueue[bus->rqueue_size++] = t;
1113+
if (t)
1114+
bus->rqueue[bus->rqueue_size++] = t;
11121115

11131116
return 1;
11141117
}

0 commit comments

Comments
 (0)