2
0
mirror of https://github.com/FWGS/xash3d-fwgs synced 2024-11-26 20:00:53 +01:00
xash3d-fwgs/utils/run-fuzzer/run-fuzzer.c

35 lines
497 B
C
Raw Normal View History

#include <dlfcn.h>
#include <stdio.h>
#include <stdlib.h>
#if !defined LIB || !defined FUNC
#error
#endif
typedef int (*FuzzFunc)(const char *Data, size_t Size);
void *handle = NULL;
FuzzFunc f = NULL;
int LLVMFuzzerTestOneInput( const char *Data, size_t Size )
{
if( !handle )
handle = dlopen( LIB, RTLD_NOW );
if( handle )
{
if( !f )
f = dlsym( handle, FUNC );
if( f )
{
return f( Data, Size );
}
}
fprintf( stderr, "Fail: %s\n", dlerror() );
abort();
return 0;
}