1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

sd-bus: fix error handling on readv()

let's make sure we collect the right error code from errno, otherwise
we'll see EPERM (i.e. error 1) for all errors readv() returns (since it
returns -1 on error), including EAGAIN.

This is definitely backport material.

A fix-up for 3691bcf3c5.

Fixes: #16699
This commit is contained in:
Lennart Poettering 2020-08-20 12:59:23 +02:00 committed by Zbigniew Jędrzejewski-Szmek
parent 7489ccc350
commit c1093c34d7

View File

@ -544,9 +544,11 @@ static int bus_socket_read_auth(sd_bus *b) {
iov = IOVEC_MAKE((uint8_t *)b->rbuffer + b->rbuffer_size, n - b->rbuffer_size);
if (b->prefer_readv)
if (b->prefer_readv) {
k = readv(b->input_fd, &iov, 1);
else {
if (k < 0)
k = -errno;
} else {
mh = (struct msghdr) {
.msg_iov = &iov,
.msg_iovlen = 1,
@ -1187,9 +1189,11 @@ int bus_socket_read_message(sd_bus *bus) {
iov = IOVEC_MAKE((uint8_t *)bus->rbuffer + bus->rbuffer_size, need - bus->rbuffer_size);
if (bus->prefer_readv)
if (bus->prefer_readv) {
k = readv(bus->input_fd, &iov, 1);
else {
if (k < 0)
k = -errno;
} else {
mh = (struct msghdr) {
.msg_iov = &iov,
.msg_iovlen = 1,