mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-25 08:55:11 +01:00
Fix ignore_too_much_pixel_data infinite loop
This commit is contained in:
1 parent
74a591ab2b
commit
5780b406dc
5 files changed
+81
-4
No files matched your search
@@ -11045,8 +11045,10 @@ wuffs_gif__decoder__copy_to_image_buffer(wuffs_gif__decoder* self,
|
|||||||
label_0_continue:;
|
label_0_continue:;
|
||||||
while (v_src_ri < ((uint64_t)(a_src.len))) {
|
while (v_src_ri < ((uint64_t)(a_src.len))) {
|
||||||
v_src = wuffs_base__slice_u8__subslice_i(a_src, v_src_ri);
|
v_src = wuffs_base__slice_u8__subslice_i(a_src, v_src_ri);
|
||||||
if ((self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1) &&
|
if (self->private_impl.f_dst_y >= self->private_impl.f_frame_rect_y1) {
|
||||||
!self->private_impl.f_quirk_enabled_ignore_too_much_pixel_data) {
|
if (self->private_impl.f_quirk_enabled_ignore_too_much_pixel_data) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return wuffs_base__error__too_much_data;
|
return wuffs_base__error__too_much_data;
|
||||||
}
|
}
|
||||||
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
v_dst = wuffs_base__table_u8__row(v_tab, self->private_impl.f_dst_y);
|
||||||
|
|||||||
@@ -1009,8 +1009,10 @@ pri func decoder.copy_to_image_buffer!(pb ptr base.pixel_buffer, src slice base.
|
|||||||
while src_ri < args.src.length() {
|
while src_ri < args.src.length() {
|
||||||
src = args.src[src_ri:]
|
src = args.src[src_ri:]
|
||||||
|
|
||||||
if (this.dst_y >= this.frame_rect_y1) and
|
if this.dst_y >= this.frame_rect_y1 {
|
||||||
(not this.quirk_enabled_ignore_too_much_pixel_data) {
|
if this.quirk_enabled_ignore_too_much_pixel_data {
|
||||||
|
return ok
|
||||||
|
}
|
||||||
return base."#too much data"
|
return base."#too much data"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1031,6 +1031,55 @@ const char* test_wuffs_gif_decode_frame_out_of_bounds() {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* test_wuffs_gif_decode_zero_width_frame() {
|
||||||
|
CHECK_FOCUS(__func__);
|
||||||
|
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
|
||||||
|
.data = global_src_slice,
|
||||||
|
});
|
||||||
|
const char* status =
|
||||||
|
read_file(&src, "test/data/artificial/gif-zero-width-frame.gif");
|
||||||
|
if (status) {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
int q;
|
||||||
|
for (q = 0; q < 2; q++) {
|
||||||
|
src.meta.ri = 0;
|
||||||
|
|
||||||
|
wuffs_gif__decoder dec;
|
||||||
|
status = wuffs_gif__decoder__initialize(
|
||||||
|
&dec, sizeof dec, WUFFS_VERSION,
|
||||||
|
WUFFS_INITIALIZE__LEAVE_INTERNAL_BUFFERS_UNINITIALIZED);
|
||||||
|
if (status) {
|
||||||
|
RETURN_FAIL("q=%d: initialize: \"%s\"", q, status);
|
||||||
|
}
|
||||||
|
wuffs_gif__decoder__set_quirk_enabled(
|
||||||
|
&dec, wuffs_gif__quirk_ignore_too_much_pixel_data, q);
|
||||||
|
|
||||||
|
wuffs_base__image_config ic = ((wuffs_base__image_config){});
|
||||||
|
status = wuffs_gif__decoder__decode_image_config(
|
||||||
|
&dec, &ic, wuffs_base__io_buffer__reader(&src));
|
||||||
|
if (status) {
|
||||||
|
RETURN_FAIL("q=%d: decode_image_config: \"%s\"", q, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
wuffs_base__pixel_buffer pb = ((wuffs_base__pixel_buffer){});
|
||||||
|
status = wuffs_base__pixel_buffer__set_from_slice(&pb, &ic.pixcfg,
|
||||||
|
global_pixel_slice);
|
||||||
|
if (status) {
|
||||||
|
RETURN_FAIL("q=%d: set_from_slice: \"%s\"", q, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
const char* got = wuffs_gif__decoder__decode_frame(
|
||||||
|
&dec, &pb, wuffs_base__io_buffer__reader(&src), global_work_slice,
|
||||||
|
NULL);
|
||||||
|
const char* want = q ? NULL : wuffs_base__error__too_much_data;
|
||||||
|
if (got != want) {
|
||||||
|
RETURN_FAIL("q=%d: decode_frame: got \"%s\", want \"%s\"", q, got, want);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
const char* test_wuffs_gif_decode_bgra_nonpremul() {
|
const char* test_wuffs_gif_decode_bgra_nonpremul() {
|
||||||
CHECK_FOCUS(__func__);
|
CHECK_FOCUS(__func__);
|
||||||
return do_test_wuffs_gif_decode("test/data/bricks-dither.gif",
|
return do_test_wuffs_gif_decode("test/data/bricks-dither.gif",
|
||||||
@@ -2108,6 +2157,7 @@ proc tests[] = {
|
|||||||
test_wuffs_gif_decode_pixel_data_not_enough, //
|
test_wuffs_gif_decode_pixel_data_not_enough, //
|
||||||
test_wuffs_gif_decode_pixel_data_too_much_sans_quirk, //
|
test_wuffs_gif_decode_pixel_data_too_much_sans_quirk, //
|
||||||
test_wuffs_gif_decode_pixel_data_too_much_with_quirk, //
|
test_wuffs_gif_decode_pixel_data_too_much_with_quirk, //
|
||||||
|
test_wuffs_gif_decode_zero_width_frame, //
|
||||||
test_wuffs_gif_frame_dirty_rect, //
|
test_wuffs_gif_frame_dirty_rect, //
|
||||||
test_wuffs_gif_num_decoded_frame_configs, //
|
test_wuffs_gif_num_decoded_frame_configs, //
|
||||||
test_wuffs_gif_num_decoded_frames, //
|
test_wuffs_gif_num_decoded_frames, //
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 40 B |
@@ -0,0 +1,23 @@
|
|||||||
|
# Feed this file to script/make-artificial.go
|
||||||
|
|
||||||
|
make gif
|
||||||
|
|
||||||
|
header
|
||||||
|
|
||||||
|
image {
|
||||||
|
imageWidthHeight 2 2
|
||||||
|
palette {
|
||||||
|
0x00 0x00 0xFF
|
||||||
|
0x11 0x00 0xFF
|
||||||
|
0x22 0x00 0xFF
|
||||||
|
0x33 0x00 0xFF
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
frame {
|
||||||
|
frameLeftTopWidthHeight 0 0 0 0
|
||||||
|
}
|
||||||
|
# The frame is 0 pixels, but we supply 1.
|
||||||
|
lzw 2 0x00
|
||||||
|
|
||||||
|
trailer
|
||||||
Reference in new issue
Block a user