Merge pull request #4701 from rgerhards/MAXPATHLEN

build issue: handle undefined MAXPATHLEN
This commit is contained in:
Rainer Gerhards 2021-10-11 14:58:11 +02:00 committed by GitHub
commit d2a8c5be8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 8 deletions

View File

@ -149,6 +149,20 @@ AS_IF([test -d "$srcdir"/.git && ! test -f "$srcdir"/.tarball-version], [in_git
AC_DEFINE_UNQUOTED([HOSTENV], "$host", [the host environment, can be queried via a system variable])
# Some Unix systems, like Gnu Hurd, don't define PATH_MAX
AC_MSG_CHECKING([for PATH_MAX])
AC_COMPILE_IFELSE( [AC_LANG_PROGRAM([[#include <limits.h>]],
[[char checker[PATH_MAX];]])],
[
AC_MSG_RESULT([yes])
],
[
AC_MSG_RESULT([no, mocking PATH_MAX = 4096])
AC_DEFINE([PATH_MAX], 4096, [replacement for missing PATH_MAX])
AC_DEFINE([MAXPATHLEN], 4096, [replacement for missing PATH_MAX]) # we assume this does not exit
]
)
# Checks for libraries.
save_LIBS=$LIBS
LIBS=

View File

@ -49,10 +49,6 @@
#include <unistd.h>
#include <sys/file.h>
#ifndef PATH_MAX
# define PATH_MAX MAXPATHLEN
#endif
#include "rsyslog.h"
#include "rainerscript.h"
#include "cfsysline.h"
@ -1101,11 +1097,7 @@ Load(uchar *const pModName, const sbool bConfLoad, struct nvlst *const lst)
uchar *pModDirCurr, *pModDirNext;
int iLoadCnt;
struct dlhandle_s *pHandle = NULL;
# ifdef PATH_MAX
uchar pathBuf[PATH_MAX+1];
# else
uchar pathBuf[4096];
# endif
uchar *pPathBuf = pathBuf;
size_t lenPathBuf = sizeof(pathBuf);
rsRetVal localRet;