diff options
Diffstat (limited to 'meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch')
-rw-r--r-- | meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch b/meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch new file mode 100644 index 0000000000..cf59ac7d06 --- /dev/null +++ b/meta/recipes-core/systemd/systemd/0010-distinguish-XSI-compliant-strerror_r-from-GNU-specif.patch | |||
@@ -0,0 +1,76 @@ | |||
1 | From 2adbe9773cd65c48eec9df96868d4a738927c8d9 Mon Sep 17 00:00:00 2001 | ||
2 | From: Chen Qi <Qi.Chen@windriver.com> | ||
3 | Date: Tue, 10 Jul 2018 15:40:17 +0800 | ||
4 | Subject: [PATCH 10/22] distinguish XSI-compliant strerror_r from GNU-specifi | ||
5 | strerror_r | ||
6 | |||
7 | XSI-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 | |||
15 | We need to distinguish between them. Otherwise, we'll get an int value | ||
16 | assigned to (char *) variable, resulting in segment fault. | ||
17 | |||
18 | Upstream-Status: Inappropriate [musl specific] | ||
19 | |||
20 | Signed-off-by: Chen Qi <Qi.Chen@windriver.com> | ||
21 | --- | ||
22 | src/libsystemd/sd-bus/bus-error.c | 11 ++++++++++- | ||
23 | src/libsystemd/sd-journal/journal-send.c | 5 +++++ | ||
24 | 2 files changed, 15 insertions(+), 1 deletion(-) | ||
25 | |||
26 | diff --git a/src/libsystemd/sd-bus/bus-error.c b/src/libsystemd/sd-bus/bus-error.c | ||
27 | index 77b2e1a0fd..fdba0e0142 100644 | ||
28 | --- a/src/libsystemd/sd-bus/bus-error.c | ||
29 | +++ b/src/libsystemd/sd-bus/bus-error.c | ||
30 | @@ -408,7 +408,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) { | ||
31 | return; | ||
32 | |||
33 | errno = 0; | ||
34 | +#ifndef __GLIBC__ | ||
35 | + strerror_r(error, m, k); | ||
36 | + x = m; | ||
37 | +#else | ||
38 | x = strerror_r(error, m, k); | ||
39 | +#endif | ||
40 | if (errno == ERANGE || strlen(x) >= k - 1) { | ||
41 | free(m); | ||
42 | k *= 2; | ||
43 | @@ -593,8 +598,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static | ||
44 | |||
45 | if (e && e->message) | ||
46 | return e->message; | ||
47 | - | ||
48 | +#ifndef __GLIBC__ | ||
49 | + strerror_r(abs(error), buf, ERRNO_BUF_LEN); | ||
50 | + return buf; | ||
51 | +#else | ||
52 | return strerror_r(abs(error), buf, ERRNO_BUF_LEN); | ||
53 | +#endif | ||
54 | } | ||
55 | |||
56 | static bool map_ok(const sd_bus_error_map *map) { | ||
57 | diff --git a/src/libsystemd/sd-journal/journal-send.c b/src/libsystemd/sd-journal/journal-send.c | ||
58 | index 69a2eb6404..1561859650 100644 | ||
59 | --- a/src/libsystemd/sd-journal/journal-send.c | ||
60 | +++ b/src/libsystemd/sd-journal/journal-send.c | ||
61 | @@ -361,7 +361,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove | ||
62 | char* j; | ||
63 | |||
64 | errno = 0; | ||
65 | +#ifndef __GLIBC__ | ||
66 | + strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); | ||
67 | + j = buffer + 8 + k; | ||
68 | +#else | ||
69 | j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k); | ||
70 | +#endif | ||
71 | if (errno == 0) { | ||
72 | char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1]; | ||
73 | |||
74 | -- | ||
75 | 2.34.1 | ||
76 | |||