From e8e2d1214a49f3c268fb5f3a92e8144b23e35243 Mon Sep 17 00:00:00 2001 From: jvoisin Date: Fri, 1 May 2026 00:48:04 +0200 Subject: 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. --- include/stdlib.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/stdlib.h b/include/stdlib.h index c95bb55..bb10a7f 100644 --- 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 -- cgit v1.3