Let gif "ignore too much" quirk skip lzw errors

The modified test/data/*/*.gif files differ by only one byte:
 00000000  47 49 46 38 39 61 02 00  02 00 81 00 00 00 00 ff  |GIF89a..........|
 00000010  11 00 ff 22 00 ff 33 00  ff 2c 00 00 00 00 02 00  |..."..3..,......|
-00000020  02 00 00 02 02 84 f1 00  3b                       |........;|
+00000020  02 00 00 02 02 84 5d 00  3b                       |......].;|

The etc-good-lzw.gif bits have changed, even though the
etc-good-lzw.etc.txt file only had comments added, due to a Go standard
library change: "compress/lzw: output a Clear code first, per GIF spec"
https://github.com/golang/go/commit/9c1dbdf60edbffeff10f58af21fa055eb0fdd29f

Updates PR #57
Updates https://crbug.com/1270631
This commit is contained in:
Nigel Tao committed 2021-11-19 13:30:23 +11:00
1 parent 3b882be500
commit e44920d382
8 files changed
+110 -5

No files matched your search

+22 -4
View File
@@ -1598,11 +1598,20 @@ test_wuffs_gif_decode_pixel_data_too_much_sans_quirk() {
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
.data = g_src_slice_u8,
});
src.meta = wuffs_base__empty_io_buffer_meta();
CHECK_STRING(read_file(
&src, "test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif"));
CHECK_STRING(do_test_wuffs_gif_decode_expecting(
src, 0, wuffs_lzw__error__bad_code, false));
src.meta = wuffs_base__empty_io_buffer_meta();
CHECK_STRING(read_file(
&src, "test/data/artificial-gif/pixel-data-too-much-good-lzw.gif"));
CHECK_STRING(do_test_wuffs_gif_decode_expecting(
src, 0, wuffs_base__error__too_much_data, false));
return do_test_wuffs_gif_decode_expecting(
src, 0, wuffs_base__error__too_much_data, false);
return NULL;
}
const char* //
@@ -1611,11 +1620,20 @@ test_wuffs_gif_decode_pixel_data_too_much_with_quirk() {
wuffs_base__io_buffer src = ((wuffs_base__io_buffer){
.data = g_src_slice_u8,
});
src.meta = wuffs_base__empty_io_buffer_meta();
CHECK_STRING(read_file(
&src, "test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif"));
CHECK_STRING(do_test_wuffs_gif_decode_expecting(
src, WUFFS_GIF__QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA, NULL, false));
src.meta = wuffs_base__empty_io_buffer_meta();
CHECK_STRING(read_file(
&src, "test/data/artificial-gif/pixel-data-too-much-good-lzw.gif"));
CHECK_STRING(do_test_wuffs_gif_decode_expecting(
src, WUFFS_GIF__QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA, NULL, false));
return do_test_wuffs_gif_decode_expecting(
src, WUFFS_GIF__QUIRK_IGNORE_TOO_MUCH_PIXEL_DATA, NULL, false);
return NULL;
}
const char* //
Binary file not shown.

After

Width:  |  Height:  |  Size: 41 B

@@ -0,0 +1,37 @@
# 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 2 2
}
# The frame area is 4 pixels and we supply 4 but then an invalid LZW code.
# Compare with pixel-data-too-much-good-lzw.gif.make-artificial.txt
#
# The disassembly (see also std/lzw/README.md) is:
#
# 0x02 LZW literal width.
# 0x02 GIF block length.
# 0x84 0xF1 = 0b1111_0001_1000_0100 (little endian).
# 0b...._...._...._.100 3-bit Clear code.
# 0b...._...._..00_0... 3-bit Literal 0x00.
# 0b...._...1_10.._.... 3-bit Copy code (2 bytes).
# 0b...._000._...._.... 3-bit Literal 0x00.
# 0b1111_...._...._.... 4-bit Invalid code.
# 0x00 GIF block terminator.
bytes 0x02 0x02 0x84 0xF1 0x00
trailer
Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 B

After

Width:  |  Height:  |  Size: 41 B

@@ -17,7 +17,21 @@ image {
frame {
frameLeftTopWidthHeight 0 0 2 2
}
# The frame is 4 pixels, but we supply 5.
# The frame area is 4 pixels but we supply 5 (that's still valid LZW data).
# Compare with pixel-data-too-much-bad-lzw.gif.make-artificial.txt
#
# The equivalent bytes' disassembly (see also std/lzw/README.md) is:
#
# 0x02 LZW literal width.
# 0x02 GIF block length.
# 0x84 0x5D = 0b0101_1101_1000_0100 (little endian).
# 0b...._...._...._.100 3-bit Clear code.
# 0b...._...._..00_0... 3-bit Literal 0x00.
# 0b...._...1_10.._.... 3-bit Copy code (2 bytes).
# 0b...._110._...._.... 3-bit Copy code (2 bytes).
# 0b0101_...._...._.... 4-bit End code.
# 0x00 GIF block terminator.
lzw 2 0x00 0x00 0x00 0x00 0x00
trailer
+1
View File
@@ -16,6 +16,7 @@ fdcc644f test/data/artificial-gif/metadata-full.gif
76c44866 test/data/artificial-gif/no-frames.gif
6ec818c3 test/data/artificial-gif/pixel-data-none.gif
5e57adb2 test/data/artificial-gif/pixel-data-not-enough.gif
3e29f88a test/data/artificial-gif/pixel-data-too-much-bad-lzw.gif
3e29f88a test/data/artificial-gif/pixel-data-too-much-good-lzw.gif
f50d1d50 test/data/artificial-gif/small-frame-interlaced.gif
beaec397 test/data/artificial-gif/transparent-index.gif