Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
aports
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Peter Shkenev
aports
Commits
6187e3ef
Commit
6187e3ef
authored
9 years ago
by
Natanael Copa
Browse files
Options
Downloads
Patches
Plain Diff
main/fortify-headers: fix realpath()
ref #4075
parent
645da2ae
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch
+56
-0
56 additions, 0 deletions
...ix-realpath-when-stdlib.h-is-included-before-limits.patch
main/fortify-headers/APKBUILD
+8
-4
8 additions, 4 deletions
main/fortify-headers/APKBUILD
with
64 additions
and
4 deletions
main/fortify-headers/0001-fix-realpath-when-stdlib.h-is-included-before-limits.patch
0 → 100644
+
56
−
0
View file @
6187e3ef
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
This diff is collapsed.
Click to expand it.
main/fortify-headers/APKBUILD
+
8
−
4
View file @
6187e3ef
...
...
@@ -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"
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment