Device support for GPTFDisk fuzzer am: 4ec5ccf629 am: 3ce22ad98b am: 4303129c64 am: bbb35811a7 am: 8d01b96853
Original change: https://android-review.googlesource.com/c/platform/tools/security/+/1359847
Change-Id: I5af1cc43522d7db1d493fd757f6f08cacee24af9
diff --git a/fuzzing/orphans/gptfdisk/Android.bp b/fuzzing/orphans/gptfdisk/Android.bp
index 14c113d..34498d3 100644
--- a/fuzzing/orphans/gptfdisk/Android.bp
+++ b/fuzzing/orphans/gptfdisk/Android.bp
@@ -9,4 +9,9 @@
],
shared_libs: ["libext2_uuid"],
corpus: ["corpus/*"],
+ target: {
+ android: {
+ cflags: ["-DGPTFDISK_FUZZER_DEVICE"],
+ },
+ },
}
diff --git a/fuzzing/orphans/gptfdisk/sgdisk_fuzz.cc b/fuzzing/orphans/gptfdisk/sgdisk_fuzz.cc
index daa955f..6a02281 100644
--- a/fuzzing/orphans/gptfdisk/sgdisk_fuzz.cc
+++ b/fuzzing/orphans/gptfdisk/sgdisk_fuzz.cc
@@ -34,7 +34,12 @@
return 0;
}
+#ifdef GPTFDISK_FUZZER_DEVICE
+#define TMPFILE_TEMPLATE "/data/local/tmp/gptfuzzXXXXXXXX\x00"
+#else
#define TMPFILE_TEMPLATE "/dev/shm/gptfuzzXXXXXXXX\x00"
+#endif
+
size_t TMPFILE_LEN = sizeof(TMPFILE_TEMPLATE);
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {