[PATCH] D58835: [Support] Treat truncation of fullpath as error
Jonas Hahnfeld via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Mar 3 12:44:17 PST 2019
Hahnfeld marked 3 inline comments as done.
Hahnfeld added inline comments.
================
Comment at: llvm/lib/Support/Unix/Path.inc:114
+ if (chars >= PATH_MAX)
+ return 1;
if (!realpath(fullpath, ret))
----------------
zturner wrote:
> efriedma wrote:
> > The use of PATH_MAX here seems dubious; in practice, many targets support paths longer than PATH_MAX. Probably should just use a raw_string_ostream or something like that instead of snprintf to a fixed buffer.
> Even better, `llvm::sys::path::join()`. I'm not sure why all of these global functions operate on raw pointers instead of LLVM's string ADTs.
I played a bit on my Arch Linux system: It's indeed possible to create paths that are longer than `PATH_MAX = 4096`. But I can't get the `realpath` nor even `cd` into there, and I'd guess that many more tools are broken.
In that case I think there's no difference between fixed buffers and the string ADTs, except that the latter are probably slower.
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58835/new/
https://reviews.llvm.org/D58835
More information about the llvm-commits
mailing list