aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2024-01-25 23:54:20 -0500
committerSam James <sam@gentoo.org>2024-08-09 11:06:18 +0100
commit15a415c49a6aeadf8c098df646643f990aa62b6a (patch)
treef6e9ab94b5643a2305b55406a07a370b1a3209e6
parentfuzz-dumpelf: fix stats argument (diff)
downloadpax-utils-15a415c49a6aeadf8c098df646643f990aa62b6a.tar.gz
pax-utils-15a415c49a6aeadf8c098df646643f990aa62b6a.tar.bz2
pax-utils-15a415c49a6aeadf8c098df646643f990aa62b6a.zip
fuzzer: fix unused setting on argc & argv
At some point the compiler changed to not propagate argument attributes from the prototype to the definition. Add a hacky macro to insert it by default instead to avoid need for (void) casts. Signed-off-by: Mike Frysinger <vapier@gentoo.org> (cherry picked from commit 6508649486444d20636d1ff15df7db7302f3c46c) Signed-off-by: Sam James <sam@gentoo.org>
-rw-r--r--dumpelf.c2
-rw-r--r--fuzz-ar.c3
-rw-r--r--paxinc.h9
3 files changed, 7 insertions, 7 deletions
diff --git a/dumpelf.c b/dumpelf.c
index 15058ee..1eb7e62 100644
--- a/dumpelf.c
+++ b/dumpelf.c
@@ -579,8 +579,6 @@ static void parseargs(int argc, char *argv[])
#if PAX_UTILS_LIBFUZZ
int LLVMFuzzerInitialize(int *argc, char ***argv)
{
- (void)argc;
- (void)argv;
(void)parseargs;
security_init(false);
return 0;
diff --git a/fuzz-ar.c b/fuzz-ar.c
index 360194f..eadcdee 100644
--- a/fuzz-ar.c
+++ b/fuzz-ar.c
@@ -15,9 +15,6 @@ static int fd;
int LLVMFuzzerInitialize(int *argc, char ***argv)
{
- (void)argc;
- (void)argv;
-
fd = memfd_create("fuzz-input.a", MFD_CLOEXEC);
if (fd == -1)
errp("memfd_create() failed");
diff --git a/paxinc.h b/paxinc.h
index b2d2b50..0d10c21 100644
--- a/paxinc.h
+++ b/paxinc.h
@@ -112,9 +112,14 @@ const char *strfileperms(const char *fname);
#define PTR_ALIGN_DOWN(base, size) ((__typeof__(base))ALIGN_DOWN((uintptr_t)(base), (size)))
#define PTR_ALIGN_UP(base, size) ((__typeof__(base))ALIGN_UP ((uintptr_t)(base), (size)))
-/* Support for libFuzzer: https://llvm.org/docs/LibFuzzer.html */
+/*
+ * Support for libFuzzer: https://llvm.org/docs/LibFuzzer.html
+ * No headers define this API, so we have to do it ourselves.
+ */
#if PAX_UTILS_LIBFUZZ
-int LLVMFuzzerInitialize(__unused__ int *argc, __unused__ char ***argv);
+int LLVMFuzzerInitialize(int *argc, char ***argv);
+/* Attributes on the prototype are ignored, so hack the definition. */
+#define LLVMFuzzerInitialize(c, v) LLVMFuzzerInitialize(__unused__ c, __unused__ v)
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size);
#endif