[PATCH] D51634: Define PATH_MAX if missing.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 4 09:21:35 PDT 2018


Meinersbur added inline comments.


================
Comment at: lib/External/ppcg/cuda_common.c:23
 {
-    char name[PATH_MAX];
+    char name[PATH_MAX + 1];
     int len;
----------------
>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.


================
Comment at: lib/External/ppcg/ppcg.h:14
+#ifndef PATH_MAX
+#define PATH_MAX 4096
+#endif
----------------
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 ()
```


Repository:
  rPLO Polly

https://reviews.llvm.org/D51634





More information about the llvm-commits mailing list