diff --git a/fuzz/jpegsave_buffer_fuzzer.cc b/fuzz/jpegsave_buffer_fuzzer.cc index 6b961c33..2b297f2b 100644 --- a/fuzz/jpegsave_buffer_fuzzer.cc +++ b/fuzz/jpegsave_buffer_fuzzer.cc @@ -12,19 +12,16 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size ) { VipsImage *image; void *buf; - size_t len, width, height, bands; + size_t len; - if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) { + 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. + /* Skip big images. They are likely to timeout. */ - if ( width * height * bands > 256 * 256 * 16 ) { + if( image->Xsize > 1024 || + image->Ysize > 1024 || + image->Bands > 10 ) { g_object_unref( image ); return( 0 ); } diff --git a/fuzz/pngsave_buffer_fuzzer.cc b/fuzz/pngsave_buffer_fuzzer.cc index 1763ce70..95726518 100644 --- a/fuzz/pngsave_buffer_fuzzer.cc +++ b/fuzz/pngsave_buffer_fuzzer.cc @@ -12,19 +12,16 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size ) { VipsImage *image; void *buf; - size_t len, width, height, bands; + size_t len; - if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) { + 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. + /* Skip big images. They are likely to timeout. */ - if ( width * height * bands > 256 * 256 * 16 ) { + if( image->Xsize > 1024 || + image->Ysize > 1024 || + image->Bands > 10 ) { g_object_unref( image ); return( 0 ); } diff --git a/fuzz/sharpen_fuzzer.cc b/fuzz/sharpen_fuzzer.cc index 84e85c5c..2bf887c9 100644 --- a/fuzz/sharpen_fuzzer.cc +++ b/fuzz/sharpen_fuzzer.cc @@ -10,34 +10,30 @@ LLVMFuzzerInitialize( int *argc, char ***argv ) extern "C" int LLVMFuzzerTestOneInput( const guint8 *data, size_t size ) { - VipsImage *in, *out; - size_t width, height, bands; + VipsImage *image, *out; double d; - if( !(in = vips_image_new_from_buffer( data, size, "", NULL )) ) { + if( !(image = 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. + /* Skip big images. They are likely to timeout. */ - if ( width * height * bands > 256 * 256 * 16 ) { - g_object_unref( in ); + if( image->Xsize > 1024 || + image->Ysize > 1024 || + image->Bands > 10 ) { + g_object_unref( image ); return( 0 ); } - if( vips_sharpen( in, &out, NULL ) ) { - g_object_unref( in ); + if( vips_sharpen( image, &out, NULL ) ) { + g_object_unref( image ); return( 0 ); } vips_avg( out, &d, NULL ); g_object_unref( out ); - g_object_unref( in ); + g_object_unref( image ); return( 0 ); } diff --git a/fuzz/thumbnail_fuzzer.cc b/fuzz/thumbnail_fuzzer.cc index f2b03ce0..e96a4e52 100644 --- a/fuzz/thumbnail_fuzzer.cc +++ b/fuzz/thumbnail_fuzzer.cc @@ -10,34 +10,30 @@ LLVMFuzzerInitialize( int *argc, char ***argv ) extern "C" int LLVMFuzzerTestOneInput( const guint8 *data, size_t size ) { - VipsImage *in, *out; - size_t width, height, bands; + VipsImage *image, *out; double d; - if( !(in = vips_image_new_from_buffer( data, size, "", NULL )) ) { + if( !(image = 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. + /* Skip big images. They are likely to timeout. */ - if ( width * height * bands > 256 * 256 * 16 ) { - g_object_unref( in ); + if( image->Xsize > 1024 || + image->Ysize > 1024 || + image->Bands > 10 ) { + g_object_unref( image ); return( 0 ); } - if( vips_thumbnail_image( in, &out, 42, NULL ) ) { - g_object_unref( in ); + 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( in ); + g_object_unref( image ); return( 0 ); } diff --git a/fuzz/webpsave_buffer_fuzzer.cc b/fuzz/webpsave_buffer_fuzzer.cc index eba52183..4a53135b 100644 --- a/fuzz/webpsave_buffer_fuzzer.cc +++ b/fuzz/webpsave_buffer_fuzzer.cc @@ -12,19 +12,16 @@ LLVMFuzzerTestOneInput( const guint8 *data, size_t size ) { VipsImage *image; void *buf; - size_t len, width, height, bands; + size_t len; - if( !(image = vips_image_new_from_buffer( data, size, "", NULL )) ) { + 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. + /* Skip big images. They are likely to timeout. */ - if ( width * height * bands > 256 * 256 * 16 ) { + if( image->Xsize > 1024 || + image->Ysize > 1024 || + image->Bands > 10 ) { g_object_unref( image ); return( 0 ); }