mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Make the GIF dirty_rect be in the frame_rect
Updates https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=11823
This commit is contained in:
1 parent
f8daf3d219
commit
0842bc7115
4 files changed
+51
-9
No files matched your search
@@ -106,6 +106,15 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
|||||||
|
|
||||||
bool seen_ok = false;
|
bool seen_ok = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
|
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||||
|
status = wuffs_gif__decoder__decode_frame_config(&dec, &fc, src_reader);
|
||||||
|
if (status) {
|
||||||
|
if ((status != wuffs_base__warning__end_of_data) || !seen_ok) {
|
||||||
|
ret = status;
|
||||||
|
}
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
|
|
||||||
status = wuffs_gif__decoder__decode_frame(&dec, &pb, src_reader, workbuf,
|
status = wuffs_gif__decoder__decode_frame(&dec, &pb, src_reader, workbuf,
|
||||||
NULL);
|
NULL);
|
||||||
if (status) {
|
if (status) {
|
||||||
@@ -115,6 +124,15 @@ const char* fuzz(wuffs_base__io_reader src_reader, uint32_t hash) {
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
seen_ok = true;
|
seen_ok = true;
|
||||||
|
|
||||||
|
wuffs_base__rect_ie_u32 frame_rect =
|
||||||
|
wuffs_base__frame_config__bounds(&fc);
|
||||||
|
wuffs_base__rect_ie_u32 dirty_rect =
|
||||||
|
wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||||
|
if (!wuffs_base__rect_ie_u32__contains_rect(&frame_rect, dirty_rect)) {
|
||||||
|
ret = "internal error: frame_rect does not contain dirty_rect";
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8639,9 +8639,6 @@ wuffs_gif__decoder__decode_image_config(wuffs_gif__decoder* self,
|
|||||||
status = wuffs_base__error__bad_call_sequence;
|
status = wuffs_base__error__bad_call_sequence;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
(memset(&self->private_impl.f_dirty_y, 0,
|
|
||||||
sizeof((wuffs_base__range_ie_u32){})),
|
|
||||||
wuffs_base__return_empty_struct());
|
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
status = wuffs_gif__decoder__decode_header(self, a_src);
|
status = wuffs_gif__decoder__decode_header(self, a_src);
|
||||||
if (status) {
|
if (status) {
|
||||||
@@ -8747,9 +8744,11 @@ wuffs_gif__decoder__frame_dirty_rect(const wuffs_gif__decoder* self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return wuffs_base__utility__make_rect_ie_u32(
|
return wuffs_base__utility__make_rect_ie_u32(
|
||||||
self->private_impl.f_frame_rect_x0,
|
wuffs_base__u32__min(self->private_impl.f_frame_rect_x0,
|
||||||
|
self->private_impl.f_width),
|
||||||
wuffs_base__range_ie_u32__get_min_incl(&self->private_impl.f_dirty_y),
|
wuffs_base__range_ie_u32__get_min_incl(&self->private_impl.f_dirty_y),
|
||||||
self->private_impl.f_frame_rect_x1,
|
wuffs_base__u32__min(self->private_impl.f_frame_rect_x1,
|
||||||
|
self->private_impl.f_width),
|
||||||
wuffs_base__range_ie_u32__get_max_excl(&self->private_impl.f_dirty_y));
|
wuffs_base__range_ie_u32__get_max_excl(&self->private_impl.f_dirty_y));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -8826,6 +8825,9 @@ wuffs_gif__decoder__decode_frame_config(wuffs_gif__decoder* self,
|
|||||||
switch (coro_susp_point) {
|
switch (coro_susp_point) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT_0;
|
||||||
|
|
||||||
|
(memset(&self->private_impl.f_dirty_y, 0,
|
||||||
|
sizeof((wuffs_base__range_ie_u32){})),
|
||||||
|
wuffs_base__return_empty_struct());
|
||||||
if (!self->private_impl.f_end_of_data) {
|
if (!self->private_impl.f_end_of_data) {
|
||||||
if (self->private_impl.f_call_sequence == 0) {
|
if (self->private_impl.f_call_sequence == 0) {
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(1);
|
||||||
|
|||||||
@@ -132,7 +132,6 @@ pub func decoder.decode_image_config?(dst nptr base.image_config, src base.io_re
|
|||||||
if this.call_sequence >= 1 {
|
if this.call_sequence >= 1 {
|
||||||
return base."?bad call sequence"
|
return base."?bad call sequence"
|
||||||
}
|
}
|
||||||
this.dirty_y.reset!()
|
|
||||||
|
|
||||||
this.decode_header?(src:args.src)
|
this.decode_header?(src:args.src)
|
||||||
this.decode_lsd?(src:args.src)
|
this.decode_lsd?(src:args.src)
|
||||||
@@ -177,10 +176,16 @@ pub func decoder.num_decoded_frames() base.u64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
|
pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
|
||||||
|
// TODO: intersect this with the frame_rect? In theory, that should be
|
||||||
|
// unnecessary, and could hide bugs, but it'd be a cheap way to ensure that
|
||||||
|
// the dirty_rect is inside the frame_rect.
|
||||||
|
//
|
||||||
|
// Note that this method is pure, so it cannot set a sticky error bit if
|
||||||
|
// the dirty_rect is too big.
|
||||||
return this.util.make_rect_ie_u32(
|
return this.util.make_rect_ie_u32(
|
||||||
min_incl_x:this.frame_rect_x0,
|
min_incl_x:this.frame_rect_x0.min(x:this.width),
|
||||||
min_incl_y:this.dirty_y.get_min_incl(),
|
min_incl_y:this.dirty_y.get_min_incl(),
|
||||||
max_excl_x:this.frame_rect_x1,
|
max_excl_x:this.frame_rect_x1.min(x:this.width),
|
||||||
max_excl_y:this.dirty_y.get_max_excl())
|
max_excl_y:this.dirty_y.get_max_excl())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -206,6 +211,8 @@ pub func decoder.restart_frame!(index base.u64, io_position base.u64) base.statu
|
|||||||
pub func decoder.decode_frame_config?(dst nptr base.frame_config, src base.io_reader) {
|
pub func decoder.decode_frame_config?(dst nptr base.frame_config, src base.io_reader) {
|
||||||
var blend base.u8
|
var blend base.u8
|
||||||
|
|
||||||
|
this.dirty_y.reset!()
|
||||||
|
|
||||||
if not this.end_of_data {
|
if not this.end_of_data {
|
||||||
if this.call_sequence == 0 {
|
if this.call_sequence == 0 {
|
||||||
this.decode_image_config?(dst:nullptr, src:args.src)
|
this.decode_image_config?(dst:nullptr, src:args.src)
|
||||||
|
|||||||
+16
-1
@@ -611,6 +611,13 @@ const char* do_test_wuffs_gif_decode_animated(
|
|||||||
if (status) {
|
if (status) {
|
||||||
RETURN_FAIL("decode_frame #%" PRIu32 ": got \"%s\"", i, status);
|
RETURN_FAIL("decode_frame #%" PRIu32 ": got \"%s\"", i, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wuffs_base__rect_ie_u32 frame_rect = wuffs_base__frame_config__bounds(&fc);
|
||||||
|
wuffs_base__rect_ie_u32 dirty_rect =
|
||||||
|
wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||||
|
if (!wuffs_base__rect_ie_u32__contains_rect(&frame_rect, dirty_rect)) {
|
||||||
|
RETURN_FAIL("internal error: frame_rect does not contain dirty_rect");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// There should be no more frames, no matter how many times we call
|
// There should be no more frames, no matter how many times we call
|
||||||
@@ -730,8 +737,8 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
|||||||
|
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
for (i = 0; true; i++) {
|
for (i = 0; true; i++) {
|
||||||
|
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
||||||
{
|
{
|
||||||
wuffs_base__frame_config fc = ((wuffs_base__frame_config){});
|
|
||||||
status = wuffs_gif__decoder__decode_frame_config(&dec, &fc, src_reader);
|
status = wuffs_gif__decoder__decode_frame_config(&dec, &fc, src_reader);
|
||||||
if (i == WUFFS_TESTLIB_ARRAY_SIZE(want_frame_config_bounds)) {
|
if (i == WUFFS_TESTLIB_ARRAY_SIZE(want_frame_config_bounds)) {
|
||||||
if (status != wuffs_base__warning__end_of_data) {
|
if (status != wuffs_base__warning__end_of_data) {
|
||||||
@@ -771,6 +778,14 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
|||||||
RETURN_FAIL("decode_frame #%" PRIu32 ": got \"%s\"", i, status);
|
RETURN_FAIL("decode_frame #%" PRIu32 ": got \"%s\"", i, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wuffs_base__rect_ie_u32 frame_rect =
|
||||||
|
wuffs_base__frame_config__bounds(&fc);
|
||||||
|
wuffs_base__rect_ie_u32 dirty_rect =
|
||||||
|
wuffs_gif__decoder__frame_dirty_rect(&dec);
|
||||||
|
if (!wuffs_base__rect_ie_u32__contains_rect(&frame_rect, dirty_rect)) {
|
||||||
|
RETURN_FAIL("internal error: frame_rect does not contain dirty_rect");
|
||||||
|
}
|
||||||
|
|
||||||
char got[(width * height) + 1];
|
char got[(width * height) + 1];
|
||||||
for (y = 0; y < height; y++) {
|
for (y = 0; y < height; y++) {
|
||||||
for (x = 0; x < width; x++) {
|
for (x = 0; x < width; x++) {
|
||||||
|
|||||||
Reference in new issue
Block a user