mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-23 08:47:56 +01:00
fuzz/c/std: report metadata in the brotli fuzzer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UZ978Fjdsyig4v3wYAZRg5
This commit is contained in:
1 file changed
+15
-5
@@ -27,10 +27,11 @@ rm -f ./a.out
|
|||||||
|
|
||||||
It should print "PASS", amongst other information, and exit(0).
|
It should print "PASS", amongst other information, and exit(0).
|
||||||
|
|
||||||
As well as decoding its input (with or without the large-window quirk and
|
As well as decoding its input (with or without the large-window quirk,
|
||||||
dictionaries), it also encodes the input (with encoder parameters, chunking,
|
metadata reporting and dictionaries), it also encodes the input (with encoder
|
||||||
flushes, metadata blocks and dst limits derived from the input's hash),
|
parameters, chunking, flushes, metadata blocks and dst limits derived from the
|
||||||
decodes the result and checks that the round trip reproduces the input.
|
input's hash), decodes the result and checks that the round trip reproduces
|
||||||
|
the input.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma clang diagnostic pop
|
#pragma clang diagnostic pop
|
||||||
@@ -387,6 +388,9 @@ fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
|
|||||||
// Enable large-window brotli for half of the inputs.
|
// Enable large-window brotli for half of the inputs.
|
||||||
wuffs_brotli__decoder__set_quirk(&dec, WUFFS_BROTLI__QUIRK_LARGE_WINDOW,
|
wuffs_brotli__decoder__set_quirk(&dec, WUFFS_BROTLI__QUIRK_LARGE_WINDOW,
|
||||||
(hash >> 1) & 1);
|
(hash >> 1) & 1);
|
||||||
|
// Report metadata blocks for half of the inputs.
|
||||||
|
wuffs_brotli__decoder__set_quirk(&dec, WUFFS_BROTLI__QUIRK_REPORT_METADATA,
|
||||||
|
(hash >> 40) & 1);
|
||||||
|
|
||||||
wuffs_base__slice_u8 workbuf =
|
wuffs_base__slice_u8 workbuf =
|
||||||
wuffs_base__make_slice_u8(g_work_buffer_array, WORK_BUFFER_ARRAY_SIZE);
|
wuffs_base__make_slice_u8(g_work_buffer_array, WORK_BUFFER_ARRAY_SIZE);
|
||||||
@@ -456,7 +460,13 @@ fuzz(wuffs_base__io_buffer* src, uint64_t hash) {
|
|||||||
status = wuffs_brotli__decoder__transform_io(&dec, &limited_dst,
|
status = wuffs_brotli__decoder__transform_io(&dec, &limited_dst,
|
||||||
&limited_src, workbuf);
|
&limited_src, workbuf);
|
||||||
src->meta.ri = limited_src.meta.ri;
|
src->meta.ri = limited_src.meta.ri;
|
||||||
if (status.repr == wuffs_base__suspension__short_read) {
|
if (status.repr == wuffs_base__note__metadata_reported) {
|
||||||
|
if (wuffs_brotli__decoder__metadata_length(&dec) > 0x1000000) {
|
||||||
|
fprintf(stderr, "wuffs_brotli__decoder__metadata_length too large\n");
|
||||||
|
intentional_segfault();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
} else if (status.repr == wuffs_base__suspension__short_read) {
|
||||||
if (limited && (src->meta.ri < src->meta.wi)) {
|
if (limited && (src->meta.ri < src->meta.wi)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user