Skip to content

Commit

Permalink
fuzzer: fix unused setting on argc & argv
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
vapier authored and thesamesam committed Aug 9, 2024
1 parent 1964a6b commit 15a415c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 0 additions & 2 deletions dumpelf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 0 additions & 3 deletions fuzz-ar.c
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
9 changes: 7 additions & 2 deletions paxinc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 15a415c

Please sign in to comment.