mirror of
https://github.com/mirror/wget.git
synced 2025-02-28 21:00:25 +08:00
Fix fuzz/ tests for OpenBSD
* fuzz/wget_*_fuzzer.c: Take care when calling exit()
This commit is contained in:
parent
93d21e4217
commit
8d8abcffdf
@ -62,10 +62,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
@ -67,16 +67,26 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int do_jump;
|
||||
static jmp_buf jmpbuf;
|
||||
#ifdef FUZZING
|
||||
void exit_wget(int status)
|
||||
{
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
#else
|
||||
#elif defined HAVE_DLFCN_H
|
||||
#include <dlfcn.h> // dlsym
|
||||
#ifndef RTLD_NEXT
|
||||
#define RTLD_NEXT RTLD_GLOBAL
|
||||
#endif
|
||||
void exit(int status)
|
||||
{
|
||||
longjmp(jmpbuf, 1);
|
||||
if (do_jump) {
|
||||
longjmp(jmpbuf, 1);
|
||||
} else {
|
||||
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
|
||||
libc_exit(status);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -93,6 +103,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
||||
CLOSE_STDERR
|
||||
|
||||
do_jump = 1;
|
||||
|
||||
if (setjmp(jmpbuf))
|
||||
goto done;
|
||||
|
||||
@ -101,6 +113,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
free((void *) ctx.parent_base);
|
||||
|
||||
done:
|
||||
do_jump = 0;
|
||||
|
||||
RESTORE_STDERR
|
||||
|
||||
return 0;
|
||||
|
@ -63,10 +63,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
@ -72,10 +72,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
@ -62,10 +62,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
@ -60,16 +60,26 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
#endif
|
||||
}
|
||||
|
||||
static int do_jump;
|
||||
static jmp_buf jmpbuf;
|
||||
#ifdef FUZZING
|
||||
void exit_wget(int status)
|
||||
{
|
||||
longjmp(jmpbuf, 1);
|
||||
}
|
||||
#else
|
||||
#elif defined HAVE_DLFCN_H
|
||||
#include <dlfcn.h> // dlsym
|
||||
#ifndef RTLD_NEXT
|
||||
#define RTLD_NEXT RTLD_GLOBAL
|
||||
#endif
|
||||
void exit(int status)
|
||||
{
|
||||
longjmp(jmpbuf, 1);
|
||||
if (do_jump) {
|
||||
longjmp(jmpbuf, 1);
|
||||
} else {
|
||||
void (*libc_exit)(int) = (void(*)(int)) dlsym (RTLD_NEXT, "exit");
|
||||
libc_exit(status);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -85,6 +95,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
||||
CLOSE_STDERR
|
||||
|
||||
do_jump = 1;
|
||||
|
||||
if (setjmp(jmpbuf))
|
||||
goto done;
|
||||
|
||||
@ -93,6 +105,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
done:
|
||||
cleanup();
|
||||
|
||||
do_jump = 0;
|
||||
|
||||
RESTORE_STDERR
|
||||
|
||||
return 0;
|
||||
|
@ -63,10 +63,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
@ -62,10 +62,6 @@ FILE *fopen_wgetrc(const char *pathname, const char *mode)
|
||||
void exit_wget(int status)
|
||||
{
|
||||
}
|
||||
#else
|
||||
void exit(int status)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
Loading…
Reference in New Issue
Block a user