diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2015-05-07 12:55:08 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-05-07 12:55:59 +0000 |
commit | 6187e3ef9917556d531d7faffbf58145dc3c2230 (patch) | |
tree | 380e07d6745006460355b6fc09b272cacfb1059b /main | |
parent | 645da2aecd2a27d9283b8436298ad0f3f3b16664 (diff) | |
download | aports-6187e3ef9917556d531d7faffbf58145dc3c2230.tar.bz2 aports-6187e3ef9917556d531d7faffbf58145dc3c2230.tar.xz |
main/fortify-headers: fix realpath()
ref #4075
Diffstat (limited to 'main')
-rw-r--r-- | main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch | 56 | ||||
-rw-r--r-- | main/fortify-headers/APKBUILD | 12 |
2 files changed, 64 insertions, 4 deletions
diff --git a/main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch b/main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch new file mode 100644 index 0000000000..17d0624ee2 --- /dev/null +++ b/main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch @@ -0,0 +1,56 @@ +From 31d62b60c5b4f1baa795537da898a83e39be9dd1 Mon Sep 17 00:00:00 2001 +From: Natanael Copa <ncopa@alpinelinux.org> +Date: Thu, 7 May 2015 14:41:36 +0200 +Subject: [PATCH fortify-headers] fix realpath when stdlib.h is included before + limits.h +To: sin@2f30.org + +If program includes stdlib.h before limits.h without _XOPEN_SOURCE, +_GNU_SOURCE or _BSD_SOURCE explicitly set, then will it always trigger +the trap with musl libc. + +This is becase stdlib.h will pull in features.h which will set +_GNU_SOURCE. This means that the fortify stdlib.h will not include +limits.h but it will still trigger the fortified realpath(), but without +PATH_MAX set. + +We fix this by including system stdlib.h before testing if limits.h +should be included. + +Since PATH_MAX is known at compile time we can also error at compile +time, instead of compiling a broken realpath(). +--- + include/stdlib.h | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/include/stdlib.h b/include/stdlib.h +index 22f1f2b..6629652 100644 +--- a/include/stdlib.h ++++ b/include/stdlib.h +@@ -1,12 +1,12 @@ + #ifndef _FORTIFY_STDLIB_H + #define _FORTIFY_STDLIB_H + ++#include_next <stdlib.h> ++ + #if defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) + #include_next <limits.h> + #endif + +-#include_next <stdlib.h> +- + #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 + + #ifdef __cplusplus +@@ -23,7 +23,7 @@ char *realpath(const char *path, char *resolved) + + if (resolved) { + #ifndef PATH_MAX +- __builtin_trap(); ++# error PATH_MAX unset. A fortified realpath will not work. + #else + bos = __builtin_object_size(resolved, 0); + if (PATH_MAX > bos) +-- +2.4.0 + diff --git a/main/fortify-headers/APKBUILD b/main/fortify-headers/APKBUILD index 72ce2fedea..2092782638 100644 --- a/main/fortify-headers/APKBUILD +++ b/main/fortify-headers/APKBUILD @@ -2,7 +2,7 @@ # Maintainer: Timo Teräs <timo.teras@iki.fi> pkgname=fortify-headers pkgver=0.4 -pkgrel=0 +pkgrel=1 pkgdesc="standalone fortify source implementation" url="http://git.2f30.org/fortify-headers/" arch="noarch" @@ -13,6 +13,7 @@ makedepends="$depends_dev" install="" subpackages="" source="http://dl.2f30.org/releases/$pkgname-$pkgver.tar.gz + 0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch " _builddir="$srcdir"/$pkgname-$pkgver @@ -36,6 +37,9 @@ package() { rm -f "$pkgdir"/usr/lib/*.la } -md5sums="99b34bbd925cbfe383252fe107cafece fortify-headers-0.4.tar.gz" -sha256sums="fedfbd951bf4d4bd30d32bef20710d6124c004037df52059a274c090c1f11a0a fortify-headers-0.4.tar.gz" -sha512sums="669bf35df5278d4557caa2c8f28e33fe3e4a03c4267eed2cc8638dcb8e705d8797e487fbb524d9ff919e2752f1dc817cef9d41f14ceb46d520661e3d2301c5f2 fortify-headers-0.4.tar.gz" +md5sums="99b34bbd925cbfe383252fe107cafece fortify-headers-0.4.tar.gz +47e6831fc0fa84075f5750b47b13d888 0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch" +sha256sums="fedfbd951bf4d4bd30d32bef20710d6124c004037df52059a274c090c1f11a0a fortify-headers-0.4.tar.gz +1216858e96afa30b093ec420d0b6d8943036d8816f54a59e3fa6ef5b5b0ee32e 0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch" +sha512sums="669bf35df5278d4557caa2c8f28e33fe3e4a03c4267eed2cc8638dcb8e705d8797e487fbb524d9ff919e2752f1dc817cef9d41f14ceb46d520661e3d2301c5f2 fortify-headers-0.4.tar.gz +5364518842709e2c25baaf9a8b7651db422f2d37c64fac690f671daa157214192933ac1821a29d31d8ddfd49dd8e2625e3dfbe6fdba3b2b899c533f0f73e4699 0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch" |