From 56c1fdfaf3d415b920aa98ab9d8f7ba2a5509708 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sun, 20 Oct 2019 03:04:05 +0000 Subject: Real fix for undefined PATH_MAX --- src/libstddjb/sarealpath.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/libstddjb/sarealpath.c') diff --git a/src/libstddjb/sarealpath.c b/src/libstddjb/sarealpath.c index 0e316b2..8c994c4 100644 --- a/src/libstddjb/sarealpath.c +++ b/src/libstddjb/sarealpath.c @@ -1,5 +1,6 @@ /* ISC license. */ +#include #include #include #include @@ -9,9 +10,20 @@ int sarealpath (stralloc *sa, char const *path) { if (sa->s) { - if (!stralloc_readyplus(sa, 128)) return -1 ; +#ifdef PATH_MAX + if (!stralloc_readyplus(sa, PATH_MAX)) return -1 ; if (!realpath(path, sa->s + sa->len)) return -1 ; sa->len += strlen(sa->s + sa->len) ; +#else + char *p = realpath(path, 0) ; + if (!p) return -1 ; + if (!stralloc_cats(sa, p) || !stralloc_0(sa)) + { + free(p) ; + return -1 ; + } + free(p) ; +#endif } else { -- cgit v1.2.3