Fix issue with running from adb shell
This fuzzer tries to write a temp file to the CWD. When run on device
from adb shell, it is denied to add a file to /. Specifying the full
path of the temp fixes the issues on device.
Bug: 203902354
Test: locally built and ran on device and host with decent coverage
Change-Id: Ie804f4209e9a38287c5424a5d2613f785d773722
diff --git a/libziparchive_writer_fuzzer.cpp b/libziparchive_writer_fuzzer.cpp
index 853a768..1f258f2 100644
--- a/libziparchive_writer_fuzzer.cpp
+++ b/libziparchive_writer_fuzzer.cpp
@@ -3,17 +3,16 @@
#include <stddef.h>
#include <stdint.h>
-#include <ziparchive/zip_writer.h>
#include "fuzzer/FuzzedDataProvider.h"
+#include <android-base/file.h>
+#include <ziparchive/zip_writer.h>
// See current fuzz coverage here:
// https://android-coverage.googleplex.com/fuzz_targets/libziparchive_writer_fuzzer/index.html
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
FuzzedDataProvider provider(data, size);
-
- std::unique_ptr<std::FILE, decltype(&fclose)> fp(fopen("fuzz", "wb"),
- &fclose);
+ std::unique_ptr<std::FILE, decltype(&fclose)> fp(tmpfile(), &fclose);
if (!fp) {
return 0;
}