std/brotli: report a too-short q10/q11 workbuf as bad workbuf length

This commit is contained in:
Claude committed 2026-10-27 02:53:07 +00:00
1 parent bef6ffc1bd
commit c8bd30dd43
3 files changed
+8 -11

No files matched your search

+4 -5
View File
@@ -43031,7 +43031,6 @@ const char wuffs_brotli__error__internal_error_inconsistent_huffman_table[] = "#
const char wuffs_brotli__error__internal_error_inconsistent_ring_buffer[] = "#brotli: internal error: inconsistent ring buffer";
const char wuffs_brotli__error__unsupported_encoder_quality[] = "#brotli: unsupported encoder quality";
const char wuffs_brotli__error__internal_error_inconsistent_encoder_state[] = "#brotli: internal error: inconsistent encoder state";
const char wuffs_brotli__error__insufficient_workbuf_length[] = "#brotli: insufficient workbuf length";
// ---------------- Private Consts
@@ -90151,7 +90150,7 @@ wuffs_brotli__encoder__encode_data(
self->private_impl.f_prev_byte2,
wuffs_base__slice_u8__subslice_j(a_wb, v_storage_len));
if (self->private_impl.f_hq_insufficient) {
return wuffs_base__make_status(wuffs_brotli__error__insufficient_workbuf_length);
return wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
}
v_ix = (self->private_impl.f_bw_ix >> 3u);
self->private_impl.f_last_bytes = ((uint32_t)(wuffs_brotli__encoder__byte_at(self, a_wb, v_ix)));
@@ -99409,7 +99408,7 @@ wuffs_brotli__encoder__create_zopfli_backward_references(
v_ok_offsets = wuffs_brotli__encoder__z_set_offsets(self, ((uint64_t)(a_wb.len)), a_num_bytes);
if ( ! v_ok_offsets) {
return wuffs_base__make_status(wuffs_brotli__error__insufficient_workbuf_length);
return wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
}
v_cmds_base = self->private_impl.f_num_cmds;
wuffs_brotli__encoder__init_zopfli_nodes(self, a_wb, ((uint64_t)(a_num_bytes + 1u)));
@@ -99459,7 +99458,7 @@ wuffs_brotli__encoder__create_hq_zopfli_backward_references(
v_ok_offsets = wuffs_brotli__encoder__z_set_offsets(self, ((uint64_t)(a_wb.len)), a_num_bytes);
if ( ! v_ok_offsets) {
return wuffs_base__make_status(wuffs_brotli__error__insufficient_workbuf_length);
return wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
}
v_max_backward_limit = ((uint64_t)((((uint64_t)(1u)) << self->private_impl.f_lgwin) - 16u));
v_store_end = a_position;
@@ -99473,7 +99472,7 @@ wuffs_brotli__encoder__create_hq_zopfli_backward_references(
v_dictionary_start = wuffs_brotli__encoder__min64(self, ((uint64_t)(v_pos + ((uint64_t)(self->private_impl.f_stream_offset)))), v_max_backward_limit);
v_max_length = ((uint64_t)(a_num_bytes - v_i));
if (((uint64_t)(v_cur_match_pos + 128u)) > self->private_impl.f_z_m_cap) {
return wuffs_base__make_status(wuffs_brotli__error__insufficient_workbuf_length);
return wuffs_base__make_status(wuffs_base__error__bad_workbuf_length);
}
v_num_found_matches = wuffs_brotli__encoder__h10_find_all_matches(self,
a_wb,
+1 -1
View File
@@ -987,7 +987,7 @@ pri func encoder.encode_data!(wb: slice base.u8, is_last: base.bool, force_flush
is_last: args.is_last, prev_byte: this.prev_byte, prev_byte2: this.prev_byte2,
s: args.wb[.. storage_len])
if this.hq_insufficient {
return "#insufficient workbuf length"
return base."#bad workbuf length"
}
ix = this.bw_ix >> 3
this.last_bytes = this.byte_at(s: args.wb, i: ix) as base.u32
+3 -5
View File
@@ -35,8 +35,6 @@
// The ZopfliCostModel's other arrays and the StartPosQueue are encoder
// fields (z_etc and zq_etc).
pri status "#insufficient workbuf length"
// Mirrors kInfinity in backward_references_hq.c: 1.7e38f.
pri const Z_INFINITY : base.u32 = 0x7EFF_C99E
@@ -1011,7 +1009,7 @@ pri func encoder.create_zopfli_backward_references!(wb: slice base.u8, num_bytes
ok_offsets = this.z_set_offsets!(wb_len: args.wb.length(), num_bytes: args.num_bytes)
if not ok_offsets {
return "#insufficient workbuf length"
return base."#bad workbuf length"
}
cmds_base = this.num_cmds
this.init_zopfli_nodes!(wb: args.wb, length: args.num_bytes ~mod+ 1)
@@ -1051,7 +1049,7 @@ pri func encoder.create_hq_zopfli_backward_references!(wb: slice base.u8, num_by
ok_offsets = this.z_set_offsets!(wb_len: args.wb.length(), num_bytes: args.num_bytes)
if not ok_offsets {
return "#insufficient workbuf length"
return base."#bad workbuf length"
}
max_backward_limit = ((1 as base.u64) << this.lgwin) ~mod- 16
store_end = args.position
@@ -1066,7 +1064,7 @@ pri func encoder.create_hq_zopfli_backward_references!(wb: slice base.u8, num_by
max_length = args.num_bytes ~mod- i
// Ensure that we have enough free slots.
if (cur_match_pos ~mod+ MAX_NUM_MATCHES_H10) > this.z_m_cap {
return "#insufficient workbuf length"
return base."#bad workbuf length"
}
num_found_matches = this.h10_find_all_matches!(wb: args.wb, cur_ix: pos, max_length: max_length,
max_backward: max_distance, dictionary_distance: dictionary_start,