mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 16:52:18 +01:00
Fix std/bmp checking bits_per_pixel too early
This commit is contained in:
1 parent
0ccdece50a
commit
6695e4aae8
2 files changed
+34
-34
No files matched your search
@@ -16386,23 +16386,6 @@ wuffs_bmp__decoder__decode_image_config(
|
|||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
self->private_impl.f_padding -= self->private_impl.f_bitmap_info_len;
|
self->private_impl.f_padding -= self->private_impl.f_bitmap_info_len;
|
||||||
if (self->private_impl.f_bitmap_info_len == 40) {
|
|
||||||
if (self->private_impl.f_bits_per_pixel >= 16) {
|
|
||||||
if (self->private_impl.f_padding >= 16) {
|
|
||||||
self->private_impl.f_bitmap_info_len = 56;
|
|
||||||
self->private_impl.f_padding -= 16;
|
|
||||||
} else if (self->private_impl.f_padding >= 12) {
|
|
||||||
self->private_impl.f_bitmap_info_len = 52;
|
|
||||||
self->private_impl.f_padding -= 12;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if ((self->private_impl.f_bitmap_info_len != 52) &&
|
|
||||||
(self->private_impl.f_bitmap_info_len != 56) &&
|
|
||||||
(self->private_impl.f_bitmap_info_len != 108) &&
|
|
||||||
(self->private_impl.f_bitmap_info_len != 124)) {
|
|
||||||
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
|
||||||
goto exit;
|
|
||||||
}
|
|
||||||
{
|
{
|
||||||
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
WUFFS_BASE__COROUTINE_SUSPENSION_POINT(8);
|
||||||
uint32_t t_3;
|
uint32_t t_3;
|
||||||
@@ -16588,6 +16571,23 @@ wuffs_bmp__decoder__decode_image_config(
|
|||||||
goto suspend;
|
goto suspend;
|
||||||
}
|
}
|
||||||
iop_a_src += self->private_data.s_decode_image_config[0].scratch;
|
iop_a_src += self->private_data.s_decode_image_config[0].scratch;
|
||||||
|
if (self->private_impl.f_bitmap_info_len == 40) {
|
||||||
|
if (self->private_impl.f_bits_per_pixel >= 16) {
|
||||||
|
if (self->private_impl.f_padding >= 16) {
|
||||||
|
self->private_impl.f_bitmap_info_len = 56;
|
||||||
|
self->private_impl.f_padding -= 16;
|
||||||
|
} else if (self->private_impl.f_padding >= 12) {
|
||||||
|
self->private_impl.f_bitmap_info_len = 52;
|
||||||
|
self->private_impl.f_padding -= 12;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if ((self->private_impl.f_bitmap_info_len != 52) &&
|
||||||
|
(self->private_impl.f_bitmap_info_len != 56) &&
|
||||||
|
(self->private_impl.f_bitmap_info_len != 108) &&
|
||||||
|
(self->private_impl.f_bitmap_info_len != 124)) {
|
||||||
|
status = wuffs_base__make_status(wuffs_bmp__error__unsupported_bmp_file);
|
||||||
|
goto exit;
|
||||||
|
}
|
||||||
if (self->private_impl.f_compression == 6) {
|
if (self->private_impl.f_compression == 6) {
|
||||||
self->private_impl.f_compression = 3;
|
self->private_impl.f_compression = 3;
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-17
@@ -106,23 +106,6 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
|||||||
}
|
}
|
||||||
this.padding -= this.bitmap_info_len
|
this.padding -= this.bitmap_info_len
|
||||||
|
|
||||||
if this.bitmap_info_len == 40 {
|
|
||||||
if this.bits_per_pixel >= 16 {
|
|
||||||
// It's poorly documented, but "length 40" data can be silently
|
|
||||||
// augmented with RGB or RGBA channel_masks (12 or 16 bytes).
|
|
||||||
if this.padding >= 16 {
|
|
||||||
this.bitmap_info_len = 56
|
|
||||||
this.padding -= 16
|
|
||||||
} else if this.padding >= 12 {
|
|
||||||
this.bitmap_info_len = 52
|
|
||||||
this.padding -= 12
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else if (this.bitmap_info_len <> 52) and (this.bitmap_info_len <> 56) and
|
|
||||||
(this.bitmap_info_len <> 108) and (this.bitmap_info_len <> 124) {
|
|
||||||
return "#unsupported BMP file"
|
|
||||||
}
|
|
||||||
|
|
||||||
width = args.src.read_u32le?()
|
width = args.src.read_u32le?()
|
||||||
if width >= 0x8000_0000 {
|
if width >= 0x8000_0000 {
|
||||||
return "#bad header"
|
return "#bad header"
|
||||||
@@ -164,6 +147,23 @@ pub func decoder.decode_image_config?(dst: nptr base.image_config, src: base.io_
|
|||||||
// the version 3 BITMAPINFOHEADER (whose total size is 40).
|
// the version 3 BITMAPINFOHEADER (whose total size is 40).
|
||||||
args.src.skip_u32?(n: 40 - 20)
|
args.src.skip_u32?(n: 40 - 20)
|
||||||
|
|
||||||
|
if this.bitmap_info_len == 40 {
|
||||||
|
if this.bits_per_pixel >= 16 {
|
||||||
|
// It's poorly documented, but "length 40" data can be silently
|
||||||
|
// augmented with RGB or RGBA channel_masks (12 or 16 bytes).
|
||||||
|
if this.padding >= 16 {
|
||||||
|
this.bitmap_info_len = 56
|
||||||
|
this.padding -= 16
|
||||||
|
} else if this.padding >= 12 {
|
||||||
|
this.bitmap_info_len = 52
|
||||||
|
this.padding -= 12
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (this.bitmap_info_len <> 52) and (this.bitmap_info_len <> 56) and
|
||||||
|
(this.bitmap_info_len <> 108) and (this.bitmap_info_len <> 124) {
|
||||||
|
return "#unsupported BMP file"
|
||||||
|
}
|
||||||
|
|
||||||
// Treat 6 (ALPHABITFIELDS) the same as 3 (BITFIELDS).
|
// Treat 6 (ALPHABITFIELDS) the same as 3 (BITFIELDS).
|
||||||
if this.compression == 6 {
|
if this.compression == 6 {
|
||||||
this.compression = 3
|
this.compression = 3
|
||||||
|
|||||||
Reference in new issue
Block a user