From 417b03a0adc069cd6fbe8065f9fd0c904f8aa3b5 Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Wed, 17 Nov 2021 12:07:44 +1100 Subject: [PATCH] Add std/png "#unsupported PNG compression method" --- release/c/wuffs-unsupported-snapshot.c | 10 ++++++---- std/png/common_consts.wuffs | 1 + std/png/decode_png.wuffs | 10 +++++----- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/release/c/wuffs-unsupported-snapshot.c b/release/c/wuffs-unsupported-snapshot.c index 17971334..f7846465 100644 --- a/release/c/wuffs-unsupported-snapshot.c +++ b/release/c/wuffs-unsupported-snapshot.c @@ -9166,6 +9166,7 @@ extern const char wuffs_png__error__bad_chunk[]; extern const char wuffs_png__error__bad_filter[]; extern const char wuffs_png__error__bad_header[]; extern const char wuffs_png__error__missing_palette[]; +extern const char wuffs_png__error__unsupported_png_compression_method[]; extern const char wuffs_png__error__unsupported_png_file[]; // ---------------- Public Consts @@ -35323,6 +35324,7 @@ const char wuffs_png__error__bad_chunk[] = "#png: bad chunk"; const char wuffs_png__error__bad_filter[] = "#png: bad filter"; const char wuffs_png__error__bad_header[] = "#png: bad header"; const char wuffs_png__error__missing_palette[] = "#png: missing palette"; +const char wuffs_png__error__unsupported_png_compression_method[] = "#png: unsupported PNG compression method"; const char wuffs_png__error__unsupported_png_file[] = "#png: unsupported PNG file"; const char wuffs_png__error__internal_error_inconsistent_chunk_type[] = "#png: internal error: inconsistent chunk type"; const char wuffs_png__error__internal_error_inconsistent_frame_bounds[] = "#png: internal error: inconsistent frame bounds"; @@ -37624,7 +37626,7 @@ wuffs_png__decoder__decode_ihdr( v_a8 = t_4; } if (v_a8 != 0) { - status = wuffs_base__make_status(wuffs_png__error__bad_header); + status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method); goto exit; } { @@ -38931,7 +38933,7 @@ wuffs_png__decoder__decode_iccp( v_c = t_1; } if (v_c != 0) { - status = wuffs_base__make_status(wuffs_png__error__bad_chunk); + status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method); goto exit; } self->private_impl.f_metadata_is_zlib_compressed = true; @@ -40725,7 +40727,7 @@ wuffs_png__decoder__tell_me_more( v_c = t_4; } if ((v_c != 0) && self->private_impl.f_metadata_is_zlib_compressed) { - status = wuffs_base__make_status(wuffs_png__error__bad_chunk); + status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method); goto exit; } self->private_impl.f_metadata_fourcc -= 2; @@ -40768,7 +40770,7 @@ wuffs_png__decoder__tell_me_more( v_c = t_6; } if (v_c != 0) { - status = wuffs_base__make_status(wuffs_png__error__bad_chunk); + status = wuffs_base__make_status(wuffs_png__error__unsupported_png_compression_method); goto exit; } self->private_impl.f_metadata_is_zlib_compressed = true; diff --git a/std/png/common_consts.wuffs b/std/png/common_consts.wuffs index cceafc1c..d85a6d8e 100644 --- a/std/png/common_consts.wuffs +++ b/std/png/common_consts.wuffs @@ -18,6 +18,7 @@ pub status "#bad chunk" pub status "#bad filter" pub status "#bad header" pub status "#missing palette" +pub status "#unsupported PNG compression method" pub status "#unsupported PNG file" pri status "#internal error: inconsistent chunk type" diff --git a/std/png/decode_png.wuffs b/std/png/decode_png.wuffs index b89e6be2..cdf3db25 100644 --- a/std/png/decode_png.wuffs +++ b/std/png/decode_png.wuffs @@ -374,7 +374,7 @@ pri func decoder.decode_ihdr?(src: base.io_reader) { // Compression. a8 = args.src.read_u8?() if a8 <> 0 { - return "#bad header" + return "#unsupported PNG compression method" } // Filter. @@ -768,14 +768,14 @@ pri func decoder.decode_iccp?(src: base.io_reader) { } } endwhile - // The compression method byte must be zero. + // Compression method. if this.chunk_length <= 0 { return "#bad chunk" } this.chunk_length -= 1 c = args.src.read_u8?() if c <> 0 { - return "#bad chunk" + return "#unsupported PNG compression method" } this.metadata_is_zlib_compressed = true @@ -1466,7 +1466,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform } c = args.src.read_u8?() if (c <> 0) and this.metadata_is_zlib_compressed { - return "#bad chunk" + return "#unsupported PNG compression method" } // Skip the language tag and translated keyword: two iterations @@ -1494,7 +1494,7 @@ pub func decoder.tell_me_more?(dst: base.io_writer, minfo: nptr base.more_inform this.chunk_length -= 1 c = args.src.read_u8?() if c <> 0 { - return "#bad chunk" + return "#unsupported PNG compression method" } this.metadata_is_zlib_compressed = true }