!38 fix error for handling on readv()

Merge pull request !38 from Hexiaowen/master
This commit is contained in:
openeuler-ci-bot 2020-09-09 19:26:39 +08:00 committed by Gitee
commit a6e91bb579
2 changed files with 58 additions and 1 deletions

View File

@ -0,0 +1,50 @@
From c1093c34d7d81b5b13cc72d4d1941000813001da Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 20 Aug 2020 12:59:23 +0200
Subject: [PATCH] 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 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1.
Fixes: #16699
---
src/libsystemd/sd-bus/bus-socket.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/libsystemd/sd-bus/bus-socket.c b/src/libsystemd/sd-bus/bus-socket.c
index fc7e8e844ab..de36a1f278a 100644
--- a/src/libsystemd/sd-bus/bus-socket.c
+++ b/src/libsystemd/sd-bus/bus-socket.c
@@ -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,

View File

@ -20,7 +20,7 @@
Name: systemd
Url: https://www.freedesktop.org/wiki/Software/systemd
Version: 246
Release: 3
Release: 4
License: MIT and LGPLv2+ and GPLv2+
Summary: System and Service Manager
@ -63,6 +63,7 @@ Patch0012: Avoid-tmp-being-mounted-as-tmpfs-without-the-user-s-.patch
Patch0013: sd-bus-properly-initialize-containers.patch
Patch0014: Revert-core-one-step-back-again-for-nspawn-we-actual.patch
Patch0015: journal-don-t-enable-systemd-journald-audit.socket-b.patch
Patch0016: sd-bus-fix-error-handling-on-readv.patch
#openEuler
Patch9001: 1509-fix-journal-file-descriptors-leak-problems.patch
@ -1488,6 +1489,12 @@ fi
%exclude /usr/share/man/man3/*
%changelog
* Wed Sep 9 2020 openEuler Buildteam <buildteam@openeuler.org> - 246-4
- Type:enhancement
- ID:NA
- SUG:NA
- DESC:fix error handling on readv
* Mon Aug 01 2020 openEuler Buildteam <buildteam@openeuler.org> - 246-3
- Type:enhancement
- ID:NA