[PATCH] D68774: [libFuzzer] Don't prefix absolute paths in fuchsia.
Marco Vanotti via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 10 03:28:35 PDT 2019
charco created this revision.
charco added reviewers: mcgrathr, jakehehrlich, phosek, kcc, aarongreen.
Herald added projects: Sanitizers, LLVM.
Herald added subscribers: llvm-commits, Sanitizers.
The ExecuteCommand function in fuchsia used to prefix the
`getOutputFile` for each command run with the `artifact_prefix` flag if
it was available, because fuchsia components don't have a writable working
directory. However, if a file with a global path is provided, fuchsia
should honor that.
An example of this is using the global `/tmp` directory to store stuff.
In fuchsia it ended up being translated to `data///tmp`, whereas we want
to make sure it is using `/tmp` (which is available to components using the
`isolated-temp` feature).
To test this I made the change, compiled fuchsia with this toolchain and
ran a fuzzer with the `-fork=1` flag (that mode makes use of the `/tmp`
directory). I also tested that normal fuzzing workflow was not affected
by this.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D68774
Files:
compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
Index: compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
===================================================================
--- compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
+++ compiler-rt/lib/fuzzer/FuzzerUtilFuchsia.cpp
@@ -407,13 +407,14 @@
// that lacks a mutable working directory. Fortunately, when this is the case
// a mutable output directory must be specified using "-artifact_prefix=...",
// so write the log file(s) there.
+ // However, we don't want to apply this logic for absolute paths.
int FdOut = STDOUT_FILENO;
if (Cmd.hasOutputFile()) {
- std::string Path;
- if (Cmd.hasFlag("artifact_prefix"))
- Path = Cmd.getFlagValue("artifact_prefix") + "/" + Cmd.getOutputFile();
- else
- Path = Cmd.getOutputFile();
+ std::string Path = Cmd.getOutputFile();
+ bool IsAbsolutePath = Path.length() > 1 && Path[0] == '/';
+ if (!IsAbsolutePath && Cmd.hasFlag("artifact_prefix")) {
+ Path = Cmd.getFlagValue("artifact_prefix") + "/" + Path;
+ }
FdOut = open(Path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0);
if (FdOut == -1) {
Printf("libFuzzer: failed to open %s: %s\n", Path.c_str(),
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D68774.224299.patch
Type: text/x-patch
Size: 1155 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191010/bdbc8533/attachment.bin>
More information about the llvm-commits
mailing list