fortify-headers

standalone fortify-source implementation
git clone git://git.2f30.org/fortify-headers
Log | Files | Refs | README | LICENSE

commit e8e2d1214a49f3c268fb5f3a92e8144b23e35243
parent 1457895d6b34cf2bfc5fddd56becaa08d4b2edfe
Author: jvoisin <julien.voisin@dustri.org>
Date:   Fri,  1 May 2026 00:48:04 +0200

Don't leak PATH_MAX' #define

Apparently, some horrible systems are leaving PATH_MAX *intentionally*
undefined, as paths can be unbounded there. We don't want to silently
introduced a limit in the trnaslation unit, so let's undefine it at the end of
the function.

Diffstat:
Minclude/stdlib.h | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/include/stdlib.h b/include/stdlib.h @@ -45,6 +45,7 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) #ifndef PATH_MAX /* see man realpath(3) */ #define PATH_MAX 4096 +#define _FORTIFY_UNDEF_PATH_MAX #endif if (__r && PATH_MAX > __bos(__r, 2)) { char __buf[PATH_MAX], *__ret; @@ -61,6 +62,10 @@ _FORTIFY_FN(realpath) char *realpath(const char *__p, char *__r) } return __orig_realpath(__p, __r); } +#ifdef _FORTIFY_UNDEF_PATH_MAX +#undef PATH_MAX +#undef _FORTIFY_UNDEF_PATH_MAX +#endif #endif #ifdef __cplusplus