summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch')
-rw-r--r--sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch89
1 files changed, 89 insertions, 0 deletions
diff --git a/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch b/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch
new file mode 100644
index 000000000000..04570f5fb3f4
--- /dev/null
+++ b/sys-auth/elogind/files/elogind-252.9-musl-strerror_r.patch
@@ -0,0 +1,89 @@
+fix strerror_r use instead of whatever this define is meant to be doing
+--
+From 0542d27ebbb250c09bdcfcf9f2ea3d27426fe522 Mon Sep 17 00:00:00 2001
+From: Chen Qi <Qi.Chen@windriver.com>
+Date: Tue, 10 Jul 2018 15:40:17 +0800
+Subject: [PATCH] distinguish XSI-compliant strerror_r from GNU-specifi
+ strerror_r
+
+XSI-compliant strerror_r and GNU-specifi strerror_r are different.
+
+ int strerror_r(int errnum, char *buf, size_t buflen);
+ /* XSI-compliant */
+
+ char *strerror_r(int errnum, char *buf, size_t buflen);
+ /* GNU-specific */
+
+We need to distinguish between them. Otherwise, we'll get an int value
+assigned to (char *) variable, resulting in segment fault.
+
+Upstream-Status: Inappropriate [musl specific]
+
+Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
+
+---
+ src/libsystemd/sd-bus/bus-error.c | 5 +++++
+ src/libsystemd/sd-journal/journal-send.c | 5 +++++
+ 2 files changed, 10 insertions(+)
+
+diff --git a/src/basic/musl_missing.h b/src/basic/musl_missing.h
+index 41c66c9..a2e1d7e 100644
+--- a/src/basic/musl_missing.h
++++ b/src/basic/musl_missing.h
+@@ -26,8 +26,6 @@ void elogind_set_program_name(const char* pcall);
+ #include <unistd.h>
+ #include <pthread.h> /* for pthread_atfork */
+
+-#define strerror_r(e, m, k) (strerror_r(e, m, k) < 0 ? strdup("strerror_r() failed") : m);
+-
+ /*
+ * Possibly TODO according to http://man7.org/linux/man-pages/man3/getenv.3.html
+ * + test if the process's effective user ID does not match its real user ID or
+diff --git a/src/libelogind/sd-bus/bus-error.c b/src/libelogind/sd-bus/bus-error.c
+index 4d687cf..1459396 100644
+--- a/src/libelogind/sd-bus/bus-error.c
++++ b/src/libelogind/sd-bus/bus-error.c
+@@ -409,7 +409,12 @@ static void bus_error_strerror(sd_bus_error *e, int error) {
+ return;
+
+ errno = 0;
++#ifndef __GLIBC__
++ strerror_r(error, m, k);
++ x = m;
++#else
+ x = strerror_r(error, m, k);
++#endif
+ if (errno == ERANGE || strlen(x) >= k - 1) {
+ free(m);
+ k *= 2;
+@@ -594,8 +599,12 @@ const char* _bus_error_message(const sd_bus_error *e, int error, char buf[static
+
+ if (e && e->message)
+ return e->message;
+-
++#ifndef __GLIBC__
++ strerror_r(abs(error), buf, ERRNO_BUF_LEN);
++ return buf;
++#else
+ return strerror_r(abs(error), buf, ERRNO_BUF_LEN);
++#endif
+ }
+
+ static bool map_ok(const sd_bus_error_map *map) {
+diff --git a/src/libelogind/sd-journal/journal-send.c b/src/libelogind/sd-journal/journal-send.c
+index 4010197..1d49868 100644
+--- a/src/libelogind/sd-journal/journal-send.c
++++ b/src/libelogind/sd-journal/journal-send.c
+@@ -444,7 +444,12 @@ static int fill_iovec_perror_and_send(const char *message, int skip, struct iove
+ char* j;
+
+ errno = 0;
++#ifndef __GLIBC__
++ strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
++ j = buffer + 8 + k;
++#else
+ j = strerror_r(_saved_errno_, buffer + 8 + k, n - 8 - k);
++#endif
+ if (errno == 0) {
+ char error[STRLEN("ERRNO=") + DECIMAL_STR_MAX(int) + 1];
+