From 5ab93db828102c862e326c393fb326d6fc78a2bb Mon Sep 17 00:00:00 2001 From: Natanael Copa Date: Mon, 24 Aug 2015 13:46:44 +0200 Subject: main/mariadb: fix segfault due to strerror_r --- ...t-with-musl-libc-due-to-bad-use-of-strerr.patch | 37 ++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 main/mariadb/0001-Fix-segfault-with-musl-libc-due-to-bad-use-of-strerr.patch (limited to 'main/mariadb/0001-Fix-segfault-with-musl-libc-due-to-bad-use-of-strerr.patch') diff --git a/main/mariadb/0001-Fix-segfault-with-musl-libc-due-to-bad-use-of-strerr.patch b/main/mariadb/0001-Fix-segfault-with-musl-libc-due-to-bad-use-of-strerr.patch new file mode 100644 index 0000000000..219cddc52a --- /dev/null +++ b/main/mariadb/0001-Fix-segfault-with-musl-libc-due-to-bad-use-of-strerr.patch @@ -0,0 +1,37 @@ +From 790b56fcbce73e3335565eb1d8f0cdab5e596dba Mon Sep 17 00:00:00 2001 +From: Natanael Copa +Date: Mon, 24 Aug 2015 11:55:59 +0200 +Subject: [PATCH] Fix segfault with musl libc due to bad use of strerror_r + +The only known implementation that has the GNU variand of strerror_r is +GNU libc. Building with musl libc and _GNU_SOURCE enables some other gnu +extensions, but musl libc does not implement the broken strerror_r. + +We fix thsi by check explicitly for GNU libc in addition to _GNU_SOURCE +and if they both are not set, then fall back to standard. + +This fixes segfault with musl libc. +--- + strings/my_vsnprintf.c | 6 +----- + 1 file changed, 1 insertion(+), 5 deletions(-) + +diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c +index 1584a9e..4a10413 100644 +--- a/strings/my_vsnprintf.c ++++ b/strings/my_vsnprintf.c +@@ -827,11 +827,7 @@ void my_strerror(char *buf, size_t len, int nr) + */ + #if defined(__WIN__) + strerror_s(buf, len, nr); +-#elif ((defined _POSIX_C_SOURCE && (_POSIX_C_SOURCE >= 200112L)) || \ +- (defined _XOPEN_SOURCE && (_XOPEN_SOURCE >= 600))) && \ +- ! defined _GNU_SOURCE +- strerror_r(nr, buf, len); /* I can build with or without GNU */ +-#elif defined _GNU_SOURCE ++#elif defined(__GLIBC__) && defined(_GNU_SOURCE) + char *r= strerror_r(nr, buf, len); + if (r != buf) /* Want to help, GNU? */ + strmake(buf, r, len - 1); /* Then don't. */ +-- +2.5.0 + -- cgit v1.2.3