Set decoder_workbuf_len_max_incl_worst_case to 1

This commit is contained in:
Nigel Tao committed 2019-02-16 12:31:23 +11:00
1 parent 77c778fb2e
commit 33eae7ae40
5 files changed
+25 -30

No files matched your search

+13 -20
View File
@@ -2779,11 +2779,11 @@ extern const char* wuffs_deflate__error__no_huffman_codes;
// ---------------- Public Consts // ---------------- Public Consts
#define WUFFS_DEFLATE__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 33280 #define WUFFS_DEFLATE__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
static const uint64_t // static const uint64_t //
wuffs_deflate__decoder_workbuf_len_max_incl_worst_case // wuffs_deflate__decoder_workbuf_len_max_incl_worst_case //
WUFFS_BASE__POTENTIALLY_UNUSED = 33280; WUFFS_BASE__POTENTIALLY_UNUSED = 1;
// ---------------- Struct Declarations // ---------------- Struct Declarations
@@ -3173,11 +3173,11 @@ extern const char* wuffs_gif__error__too_much_pixel_data;
// ---------------- Public Consts // ---------------- Public Consts
#define WUFFS_GIF__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 65535 #define WUFFS_GIF__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
static const uint64_t // static const uint64_t //
wuffs_gif__decoder_workbuf_len_max_incl_worst_case // wuffs_gif__decoder_workbuf_len_max_incl_worst_case //
WUFFS_BASE__POTENTIALLY_UNUSED = 65535; WUFFS_BASE__POTENTIALLY_UNUSED = 1;
// ---------------- Struct Declarations // ---------------- Struct Declarations
@@ -3480,11 +3480,11 @@ extern const char* wuffs_gzip__error__bad_header;
// ---------------- Public Consts // ---------------- Public Consts
#define WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 33280 #define WUFFS_GZIP__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
static const uint64_t // static const uint64_t //
wuffs_gzip__decoder_workbuf_len_max_incl_worst_case // wuffs_gzip__decoder_workbuf_len_max_incl_worst_case //
WUFFS_BASE__POTENTIALLY_UNUSED = 33280; WUFFS_BASE__POTENTIALLY_UNUSED = 1;
// ---------------- Struct Declarations // ---------------- Struct Declarations
@@ -3655,11 +3655,11 @@ extern const char* wuffs_zlib__error__bad_parity_check;
// ---------------- Public Consts // ---------------- Public Consts
#define WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 33280 #define WUFFS_ZLIB__DECODER_WORKBUF_LEN_MAX_INCL_WORST_CASE 1
static const uint64_t // static const uint64_t //
wuffs_zlib__decoder_workbuf_len_max_incl_worst_case // wuffs_zlib__decoder_workbuf_len_max_incl_worst_case //
WUFFS_BASE__POTENTIALLY_UNUSED = 33280; WUFFS_BASE__POTENTIALLY_UNUSED = 1;
// ---------------- Struct Declarations // ---------------- Struct Declarations
@@ -6277,7 +6277,7 @@ wuffs_deflate__decoder__workbuf_len(const wuffs_deflate__decoder* self) {
return ((wuffs_base__range_ii_u64){0}); return ((wuffs_base__range_ii_u64){0});
} }
return wuffs_base__utility__make_range_ii_u64(33280, 33280); return wuffs_base__utility__make_range_ii_u64(1, 1);
} }
// -------- func deflate.decoder.decode_io_writer // -------- func deflate.decoder.decode_io_writer
@@ -8791,9 +8791,7 @@ wuffs_gif__decoder__workbuf_len(const wuffs_gif__decoder* self) {
return ((wuffs_base__range_ii_u64){0}); return ((wuffs_base__range_ii_u64){0});
} }
return wuffs_base__utility__make_range_ii_u64( return wuffs_base__utility__make_range_ii_u64(1, 1);
((uint64_t)(self->private_impl.f_width)),
((uint64_t)(self->private_impl.f_width)));
} }
// -------- func gif.decoder.restart_frame // -------- func gif.decoder.restart_frame
@@ -10492,12 +10490,7 @@ wuffs_gif__decoder__decode_id_part2(wuffs_gif__decoder* self,
(iop_a_src += 1, wuffs_base__return_empty_struct()); (iop_a_src += 1, wuffs_base__return_empty_struct());
} }
label_1_break:; label_1_break:;
if (((uint64_t)(self->private_impl.f_width)) < if (1 > ((uint64_t)(a_workbuf.len))) {
((uint64_t)(a_workbuf.len))) {
a_workbuf = wuffs_base__slice_u8__subslice_j(
a_workbuf, ((uint64_t)(self->private_impl.f_width)));
} else if (((uint64_t)(self->private_impl.f_width)) >
((uint64_t)(a_workbuf.len))) {
status = wuffs_base__error__bad_workbuf_length; status = wuffs_base__error__bad_workbuf_length;
goto exit; goto exit;
} }
@@ -10829,7 +10822,7 @@ wuffs_gzip__decoder__workbuf_len(const wuffs_gzip__decoder* self) {
return ((wuffs_base__range_ii_u64){0}); return ((wuffs_base__range_ii_u64){0});
} }
return wuffs_base__utility__make_range_ii_u64(33280, 33280); return wuffs_base__utility__make_range_ii_u64(1, 1);
} }
// -------- func gzip.decoder.decode_io_writer // -------- func gzip.decoder.decode_io_writer
@@ -11302,7 +11295,7 @@ wuffs_zlib__decoder__workbuf_len(const wuffs_zlib__decoder* self) {
return ((wuffs_base__range_ii_u64){0}); return ((wuffs_base__range_ii_u64){0});
} }
return wuffs_base__utility__make_range_ii_u64(33280, 33280); return wuffs_base__utility__make_range_ii_u64(1, 1);
} }
// -------- func zlib.decoder.decode_io_writer // -------- func zlib.decoder.decode_io_writer
+3 -1
View File
@@ -31,7 +31,9 @@ pri status "?internal error: inconsistent I/O"
pri status "?internal error: inconsistent distance" pri status "?internal error: inconsistent distance"
pri status "?internal error: inconsistent n_bits" pri status "?internal error: inconsistent n_bits"
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 32768 + 512 // TODO: replace the placeholder 1 value with either 0 or (32768 + 512),
// depending on whether we'll move decoder.history into the workbuf.
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
// The next two tables were created by script/print-deflate-magic-numbers.go. // The next two tables were created by script/print-deflate-magic-numbers.go.
// //
+7 -7
View File
@@ -24,8 +24,10 @@ pub status "?too much pixel data"
pri status "?internal error: inconsistent ri/wi" pri status "?internal error: inconsistent ri/wi"
// TODO: reference lzw.decoder_workbuf_len_max_incl_worst_case. // TODO: replace the placeholder 1 value with either 0 or 0xFFFF (plus
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 0xFFFF // lzw.decoder_workbuf_len_max_incl_worst_case), depending on whether we'll
// need a per-pixel-row workbuf.
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
// See the spec appendix E "Interlaced Images" on page 29. The first element // See the spec appendix E "Interlaced Images" on page 29. The first element
// represents either that the frame was non-interlaced, or that all interlace // represents either that the frame was non-interlaced, or that all interlace
@@ -192,8 +194,8 @@ pub func decoder.frame_dirty_rect() base.rect_ie_u32 {
pub func decoder.workbuf_len() base.range_ii_u64 { pub func decoder.workbuf_len() base.range_ii_u64 {
return this.util.make_range_ii_u64( return this.util.make_range_ii_u64(
min_incl:this.width as base.u64, min_incl:decoder_workbuf_len_max_incl_worst_case,
max_incl:this.width as base.u64) max_incl:decoder_workbuf_len_max_incl_worst_case)
} }
pub func decoder.restart_frame!(index base.u64, io_position base.u64) base.status { pub func decoder.restart_frame!(index base.u64, io_position base.u64) base.status {
@@ -717,9 +719,7 @@ pri func decoder.decode_id_part2?(dst ptr base.pixel_buffer, src base.io_reader,
args.src.skip_fast!(actual:1, worst_case:1) args.src.skip_fast!(actual:1, worst_case:1)
} }
if (this.width as base.u64) < args.workbuf.length() { if decoder_workbuf_len_max_incl_worst_case > args.workbuf.length() {
args.workbuf = args.workbuf[:this.width as base.u64]
} else if (this.width as base.u64) > args.workbuf.length() {
return base."?bad workbuf length" return base."?bad workbuf length"
} }
+1 -1
View File
@@ -21,7 +21,7 @@ pub status "?bad encoding flags"
pub status "?bad header" pub status "?bad header"
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case. // TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 32768 + 512 pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
pub struct decoder?( pub struct decoder?(
ignore_checksum base.bool, ignore_checksum base.bool,
+1 -1
View File
@@ -23,7 +23,7 @@ pub status "?bad parity check"
pri status "?TODO: unsupported preset dictionary" pri status "?TODO: unsupported preset dictionary"
// TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case. // TODO: reference deflate.decoder_workbuf_len_max_incl_worst_case.
pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 32768 + 512 pub const decoder_workbuf_len_max_incl_worst_case base.u64 = 1
pub struct decoder?( pub struct decoder?(
ignore_checksum base.bool, ignore_checksum base.bool,