Skip to content

Commit

Permalink
[libFuzzer] Print a correct error message when a directory can't be
Browse files Browse the repository at this point in the history
opened.

Summary:
Currently if the directory cannot be opened for a reason other than
non-existence (e.g. too many open file descriptors) the error message
printed is incredibly confusing.

Patch By: Alex Gaynor

Reviewers: kcc, morehouse

Reviewed By: morehouse

Subscribers: delcypher, llvm-commits, Sanitizers

Differential Revision: https://reviews.llvm.org/D45322

llvm-svn: 329438
  • Loading branch information
morehouse committed Apr 6, 2018
1 parent aca8f32 commit fcc97b2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion compiler-rt/lib/fuzzer/FuzzerIOPosix.cpp
Expand Up @@ -54,7 +54,7 @@ void ListFilesInDirRecursive(const std::string &Dir, long *Epoch,

DIR *D = opendir(Dir.c_str());
if (!D) {
Printf("No such directory: %s; exiting\n", Dir.c_str());
Printf("%s: %s; exiting\n", strerror(errno), Dir.c_str());
exit(1);
}
while (auto E = readdir(D)) {
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/fuzzer/fuzzer-dirs.test
Expand Up @@ -17,5 +17,5 @@ LONG: INFO: -max_len is not provided; libFuzzer will not generate inputs larger
RUN: rm -rf %t/SUB1

RUN: not %t-SimpleTest NONEXISTENT_DIR 2>&1 | FileCheck %s --check-prefix=NONEXISTENT_DIR
NONEXISTENT_DIR: No such directory: NONEXISTENT_DIR; exiting
NONEXISTENT_DIR: No such file or directory: NONEXISTENT_DIR; exiting

0 comments on commit fcc97b2

Please sign in to comment.