[compiler-rt] r329438 - [libFuzzer] Print a correct error message when a directory can't be

Matt Morehouse via llvm-commits llvm-commits at lists.llvm.org
Fri Apr 6 11:15:24 PDT 2018


Author: morehouse
Date: Fri Apr  6 11:15:24 2018
New Revision: 329438

URL: http://llvm.org/viewvc/llvm-project?rev=329438&view=rev
Log:
[libFuzzer] Print a correct error message when a directory can't be
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

Modified:
    compiler-rt/trunk/lib/fuzzer/FuzzerIOPosix.cpp
    compiler-rt/trunk/test/fuzzer/fuzzer-dirs.test

Modified: compiler-rt/trunk/lib/fuzzer/FuzzerIOPosix.cpp
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/fuzzer/FuzzerIOPosix.cpp?rev=329438&r1=329437&r2=329438&view=diff
==============================================================================
--- compiler-rt/trunk/lib/fuzzer/FuzzerIOPosix.cpp (original)
+++ compiler-rt/trunk/lib/fuzzer/FuzzerIOPosix.cpp Fri Apr  6 11:15:24 2018
@@ -54,7 +54,7 @@ void ListFilesInDirRecursive(const std::
 
   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)) {

Modified: compiler-rt/trunk/test/fuzzer/fuzzer-dirs.test
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/test/fuzzer/fuzzer-dirs.test?rev=329438&r1=329437&r2=329438&view=diff
==============================================================================
--- compiler-rt/trunk/test/fuzzer/fuzzer-dirs.test (original)
+++ compiler-rt/trunk/test/fuzzer/fuzzer-dirs.test Fri Apr  6 11:15:24 2018
@@ -17,5 +17,5 @@ LONG: INFO: -max_len is not provided; li
 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
 




More information about the llvm-commits mailing list