libvips/fuzz/thumbnail_fuzzer.cc
John Cupitt cb1634dd31 block fuzz data over 100kb
Many codecs can take a huge amount of time attempting to read large
random objects. jpeg_read_header(), for example, can take ~10s on a 1mb
of random data.

Ignore fuzz objects over 100kb.

See https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=24383
2020-07-25 14:46:44 +01:00

41 lines
697 B
C++

#include <vips/vips.h>
extern "C" int
LLVMFuzzerInitialize( int *argc, char ***argv )
{
vips_concurrency_set( 1 );
return( 0 );
}
extern "C" int
LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *image, *out;
double d;
if( size > 100 * 1024 * 1024 )
return( 0 );
if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) )
return( 0 );
if( image->Xsize > 100 ||
image->Ysize > 100 ||
image->Bands > 4 ) {
g_object_unref( image );
return( 0 );
}
if( vips_thumbnail_image( image, &out, 42, NULL ) ) {
g_object_unref( image );
return( 0 );
}
vips_avg( out, &d, NULL );
g_object_unref( out );
g_object_unref( image );
return( 0 );
}