Page MenuHomePhabricator

Define PATH_MAX if missing.
AbandonedPublic

Authored by DiamondLovesYou on Sep 4 2018, 8:11 AM.

Details

Summary

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.

Event Timeline

DiamondLovesYou created this revision.Sep 4 2018, 8:11 AM
grosser accepted this revision.Sep 4 2018, 9:18 AM

This LGTM.

This revision is now accepted and ready to land.Sep 4 2018, 9:18 AM
Meinersbur added inline comments.Sep 4 2018, 9:19 AM
lib/External/ppcg/cuda_common.c
23

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.

lib/External/ppcg/ppcg.h
14

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 ()
DiamondLovesYou abandoned this revision.Sep 6 2018, 9:40 AM

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.