Some platforms lack any PATH_MAX definition. This defines PATH_MAX to a
sensibly large size in such cases.
Also, add one to PATH_MAX for the null byte.
From Linux' limits.h:
#define PATH_MAX 4096 /* # chars in a path name including nul */
I'd conclude that it is not necessary to reserve an additional char for the terminating nul.
While maybe safe in practice, I don't think this is a good idea from a security/software quality perspective. But we can define PATH_MAX for platforms we know the the value of.
E.g. in lib/External/CMakeLists.txt we already have
if(MSVC) # In the Windows API (with some exceptions), the maximum length for a path is # MAX_PATH, which is defined as 260 characters. target_compile_definitions(PollyPPCG PRIVATE "-DPATH_MAX=260") endif ()
Thanks for the comments, everyone. This was originally submitted to fix a rust-lang buildbot, which I've learned is based on CentOS 5.5 (yes). Anyhow, I've fixed the issue on that particular buildbot by defining PATH_MAX in C(XX)FLAGS. Thus this patch isn't needed anymore. Thanks again.