std/jpeg: reject 2 (not 1, 3 or 4) components

This commit is contained in:
Nigel Tao committed 2023-05-22 14:11:46 +10:00
1 parent 7d73f3cfa4
commit ac3bd9cdba
2 files changed
+8

No files matched your search

+5
View File
@@ -8636,6 +8636,7 @@ extern const char wuffs_jpeg__error__missing_huffman_table[];
extern const char wuffs_jpeg__error__missing_quantization_table[];
extern const char wuffs_jpeg__error__truncated_input[];
extern const char wuffs_jpeg__error__unsupported_arithmetic_coding[];
extern const char wuffs_jpeg__error__unsupported_color_model[];
extern const char wuffs_jpeg__error__unsupported_fractional_sampling[];
extern const char wuffs_jpeg__error__unsupported_hierarchical_coding[];
extern const char wuffs_jpeg__error__unsupported_implicit_height[];
@@ -36596,6 +36597,7 @@ const char wuffs_jpeg__error__missing_huffman_table[] = "#jpeg: missing Huffman
const char wuffs_jpeg__error__missing_quantization_table[] = "#jpeg: missing Quantization table";
const char wuffs_jpeg__error__truncated_input[] = "#jpeg: truncated input";
const char wuffs_jpeg__error__unsupported_arithmetic_coding[] = "#jpeg: unsupported arithmetic coding";
const char wuffs_jpeg__error__unsupported_color_model[] = "#jpeg: unsupported color model";
const char wuffs_jpeg__error__unsupported_fractional_sampling[] = "#jpeg: unsupported fractional sampling";
const char wuffs_jpeg__error__unsupported_hierarchical_coding[] = "#jpeg: unsupported hierarchical coding";
const char wuffs_jpeg__error__unsupported_implicit_height[] = "#jpeg: unsupported implicit height";
@@ -38436,6 +38438,9 @@ wuffs_jpeg__decoder__decode_sof(
if ((v_c == 0) || (v_c > 4)) {
status = wuffs_base__make_status(wuffs_jpeg__error__bad_sof_marker);
goto exit;
} else if (v_c == 2) {
status = wuffs_base__make_status(wuffs_jpeg__error__unsupported_color_model);
goto exit;
}
self->private_impl.f_num_components = ((uint32_t)(v_c));
if (self->private_impl.f_payload_length != (3 * self->private_impl.f_num_components)) {
+3
View File
@@ -23,6 +23,7 @@ pub status "#missing Huffman table"
pub status "#missing Quantization table"
pub status "#truncated input"
pub status "#unsupported arithmetic coding"
pub status "#unsupported color model"
pub status "#unsupported fractional sampling"
pub status "#unsupported hierarchical coding"
pub status "#unsupported implicit height"
@@ -414,6 +415,8 @@ pri func decoder.decode_sof?(src: base.io_reader) {
c = args.src.read_u8?()
if (c == 0) or (c > 4) {
return "#bad SOF marker"
} else if c == 2 {
return "#unsupported color model"
}
this.num_components = c as base.u32
if this.payload_length <> (3 * this.num_components) {