skip large images in the fuzzers not in the lib

This reverts commit 0accdf858b.
This commit is contained in:
Oscar Mira 2019-08-02 17:28:16 +02:00
parent 4ce745dbee
commit 45de60e571
6 changed files with 51 additions and 16 deletions

View File

@ -11,13 +11,24 @@ extern "C" int
LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *image;
size_t len;
void *buf;
size_t len, width, height, bands;
if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) {
return( 0 );
}
width = image->Xsize;
height = image->Ysize;
bands = image->Bands;
/* Skip big images. It is likely to timeout.
*/
if ( width * height * bands > 256 * 256 * 16 ) {
g_object_unref( image );
return( 0 );
}
if( vips_jpegsave_buffer( image, &buf, &len, NULL ) ) {
g_object_unref( image );
return( 0 );

View File

@ -12,12 +12,23 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *image;
void *buf;
size_t len;
size_t len, width, height, bands;
if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) {
return( 0 );
}
width = image->Xsize;
height = image->Ysize;
bands = image->Bands;
/* Skip big images. It is likely to timeout.
*/
if ( width * height * bands > 256 * 256 * 16 ) {
g_object_unref( image );
return( 0 );
}
if( vips_pngsave_buffer( image, &buf, &len, NULL ) ) {
g_object_unref( image );
return( 0 );

View File

@ -11,12 +11,24 @@ extern "C" int
LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *in, *out;
size_t width, height, bands;
double d;
if( !(in = vips_image_new_from_buffer( data, size, "", NULL )) ) {
return( 0 );
}
width = in->Xsize;
height = in->Ysize;
bands = in->Bands;
/* Skip big images. It is likely to timeout.
*/
if ( width * height * bands > 256 * 256 * 16 ) {
g_object_unref( in );
return( 0 );
}
if( vips_sharpen( in, &out, NULL ) ) {
g_object_unref( in );
return( 0 );

View File

@ -11,7 +11,7 @@ extern "C" int
LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *in, *out;
size_t width, height;
size_t width, height, bands;
double d;
if( !(in = vips_image_new_from_buffer( data, size, "", NULL )) ) {
@ -20,10 +20,11 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
width = in->Xsize;
height = in->Ysize;
bands = in->Bands;
/* Skip big images. It is likely to timeout.
*/
if ( width * height > 256 * 256 ) {
if ( width * height * bands > 256 * 256 * 16 ) {
g_object_unref( in );
return( 0 );
}

View File

@ -12,12 +12,23 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size )
{
VipsImage *image;
void *buf;
size_t len;
size_t len, width, height, bands;
if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) {
return( 0 );
}
width = image->Xsize;
height = image->Ysize;
bands = image->Bands;
/* Skip big images. It is likely to timeout.
*/
if ( width * height * bands > 256 * 256 * 16 ) {
g_object_unref( image );
return( 0 );
}
if( vips_webpsave_buffer( image, &buf, &len, NULL ) ) {
g_object_unref( image );
return( 0 );

View File

@ -382,17 +382,6 @@ int
vips_image_pipeline_array( VipsImage *image,
VipsDemandStyle hint, VipsImage **in )
{
/* Ban large images while we are fuzzing. They cause unintersting
* timeouts and OOMs.
*/
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
if( (size_t) image->Xsize * image->Ysize * image->Bands > 1000000 ) {
vips_error( "vips_image_pipeline_array",
"%s", _( "no large images during fuzzing" ) );
return( -1 );
}
#endif /*FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION*/
/* This function can be called more than once per output image. For
* example, jpeg header load will call this once on ->out to set the
* default hint, then later call it again to connect the output image