summaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch')
-rw-r--r--meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch62
1 files changed, 62 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch b/meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch
new file mode 100644
index 0000000000..5c78cabbaf
--- /dev/null
+++ b/meta/recipes-core/systemd/systemd/0020-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch
@@ -0,0 +1,62 @@
1From dd53dc9b9542cbd2c39a39096941dfed70d06506 Mon Sep 17 00:00:00 2001
2From: Chen Qi <Qi.Chen@windriver.com>
3Date: Tue, 10 Jul 2018 15:40:17 +0800
4Subject: [PATCH 20/20] distinguish XSI-compliant strerror_r from GNU-specifi
5 strerror_r
6
7XSI-compliant strerror_r and GNU-specifi strerror_r are different.
8
9 int strerror_r(int errnum, char *buf, size_t buflen);
10 /* XSI-compliant */
11
12 char *strerror_r(int errnum, char *buf, size_t buflen);
13 /* GNU-specific */
14
15We need to distinguish between them. Otherwise, we'll get an int value
16assigned to (char *) variable, resulting in segment fault.
17
18Upstream-Status: Inappropriate [musl specific]
19
20Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
21---
22 src/journal/journal-send.c | 5 +++++
23 src/libsystemd/sd-bus/bus-error.c | 5 +++++
24 2 files changed, 10 insertions(+)
25
26diff --git a/src/journal/journal-send.c b/src/journal/journal-send.c
27index 65bcbcd2e..aef80dd8f 100644
28--- a/src/journal/journal-send.c
29+++ b/src/journal/journal-send.c
30@@ -337,7 +337,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
31 char* j;
32
33 errno = 0;
34+#ifndef __GLIBC__
35+ strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
36+ j = buffer + 8 + k;
37+#else
38 j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
39+#endif
40 if (errno == 0) {
41 char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1];
42
43diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c
44index ec359ac13..d2aa86cea 100644
45--- a/src/libsystemd/sd-bus/bus-error.c
46+++ b/src/libsystemd/sd-bus/bus-error.c
47@@ -362,7 +362,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
48 return;
49
50 errno = 0;
51+#ifndef __GLIBC__
52+ strerror_r(error, m, k);
53+ x = m;
54+#else
55 x = strerror_r(error, m, k);
56+#endif
57 if (errno == ERANGE || strlen(x) >= k - 1) {
58 free(m);
59 k *= 2;
60--
612.11.0
62