From ac3bd9cdba0963bc79bb082e89a9df363b1b744c Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 22 May 2023 14:11:46 +1000 Subject: [PATCH] std/jpeg: reject 2 (not 1, 3 or 4) components --- release/c/wuffs-unsupported-snapshot.c | 5 +++++ std/jpeg/decode_jpeg.wuffs | 3 +++ 2 files changed, 8 insertions(+) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 288e9483..13643314 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -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)) { diff --git a/std/jpeg/decode_jpeg.wuffs b/std/jpeg/decode_jpeg.wuffs index 5a2715b2..cdd26fd0 100644 --- a/std/jpeg/decode_jpeg.wuffs +++ b/std/jpeg/decode_jpeg.wuffs @@ -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) {