diff options
author | Davide Italiano <davide@freebsd.org> | 2018-01-09 17:27:45 +0000 |
---|---|---|
committer | Davide Italiano <davide@freebsd.org> | 2018-01-09 17:27:45 +0000 |
commit | 4762c069dead49ba96c05da0b827f52fad117164 (patch) | |
tree | 578bb4e32df52e54a7c7ab0be29c2c3e55eb1078 /llvm/lib | |
parent | 9aaf5d3e717e14d0a06fd6598c988537791e55b9 (diff) | |
download | bcm5719-llvm-4762c069dead49ba96c05da0b827f52fad117164.tar.gz bcm5719-llvm-4762c069dead49ba96c05da0b827f52fad117164.zip |
[Support] Use realpath(3) instead of trying to open a file.
If we don't have read permissions on the directory the call would
fail.
<rdar://problem/35871293>
llvm-svn: 322095
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Support/Unix/Path.inc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Support/Unix/Path.inc b/llvm/lib/Support/Unix/Path.inc index 2ecb97316c8..220162d1c19 100644 --- a/llvm/lib/Support/Unix/Path.inc +++ b/llvm/lib/Support/Unix/Path.inc @@ -860,12 +860,12 @@ std::error_code real_path(const Twine &path, SmallVectorImpl<char> &dest, return real_path(Storage, dest, false); } - int fd; - std::error_code EC = openFileForRead(path, fd, &dest); - - if (EC) - return EC; - ::close(fd); + SmallString<128> Storage; + StringRef P = path.toNullTerminatedStringRef(Storage); + char Buffer[PATH_MAX]; + if (::realpath(P.begin(), Buffer) == nullptr) + return std::error_code(errno, std::generic_category()); + dest.append(Buffer, Buffer + strlen(Buffer)); return std::error_code(); } |