Add fuzz/c/std/gif_fuzzer.c quirks
@@ -61,6 +61,27 @@ It should print "PASS", amongst other information, and exit(0).
#include "../fuzzlib/fuzzlib.c"
#include "../fuzzlib/fuzzlib_image_decoder.c"
+void set_quirks(wuffs_gif__decoder* dec, uint64_t hash_55_bits) {
+ uint32_t quirks[] = {
+ WUFFS_GIF__QUIRK_DELAY_NUM_DECODED_FRAMES,
+ WUFFS_GIF__QUIRK_FIRST_FRAME_LOCAL_PALETTE_MEANS_BLACK_BACKGROUND,
+ WUFFS_GIF__QUIRK_HONOR_BACKGROUND_COLOR,
+ WUFFS_GIF__QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA,
+ WUFFS_GIF__QUIRK_IMAGE_BOUNDS_ARE_STRICT,
+ WUFFS_GIF__QUIRK_REJECT_EMPTY_FRAME,
+ WUFFS_GIF__QUIRK_REJECT_EMPTY_PALETTE,
+ 0,
+ };
+
+ uint32_t i;
+ for (i = 0; quirks[i]; i++) {
+ uint64_t bit = 1 << (i % 55);
+ if (hash_55_bits & bit) {
+ wuffs_gif__decoder__set_quirk_enabled(dec, quirks[i], true);
+ }
+ }
+}
+
const char* //
fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
wuffs_gif__decoder dec;
@@ -68,10 +89,13 @@ fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
&dec, sizeof dec, WUFFS_VERSION,
(hash & 1) ? WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED : 0);
hash >>= 1;
+ uint64_t hash_8_bits = hash & 0xFF;
+ uint64_t hash_55_bits = hash >> 8;
if (!wuffs_base__status__is_ok(&status)) {
return wuffs_base__status__message(&status);
}
+ set_quirks(&dec, hash_55_bits);
return fuzz_image_decoder(
- src, hash,
+ src, hash_8_bits,
wuffs_gif__decoder__upcast_as__wuffs_base__image_decoder(&dec));
}
