Skip to content

Commit

Permalink
oss-fuzz: Add fuzzing targets for simplified READ API
Browse files Browse the repository at this point in the history
New target added to libpng_read_fuzzer.cc for simplified READ API.
  • Loading branch information
tyler92 committed Sep 9, 2024
1 parent e4a31f0 commit 993638f
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions contrib/oss-fuzz/libpng_read_fuzzer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -204,5 +204,21 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
png_read_end(png_handler.png_ptr, png_handler.end_info_ptr);

PNG_CLEANUP

#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
// Simplified READ API
png_image image;
memset(&image, 0, (sizeof image));
image.version = PNG_IMAGE_VERSION;

if (!png_image_begin_read_from_memory(&image, data, size)) {
return 0;
}

image.format = PNG_FORMAT_RGBA;
std::vector<png_byte> buffer(PNG_IMAGE_SIZE(image));
png_image_finish_read(&image, NULL, buffer.data(), 0, NULL);
#endif

return 0;
}

0 comments on commit 993638f

Please sign in to comment.