From 20431706a863f92cb37dc512fef6e48d192aaf2c Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:11:38 +0200 Subject: Merging upstream version 1.66.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/miniz_oxide/src/inflate/mod.rs | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'vendor/miniz_oxide/src') diff --git a/vendor/miniz_oxide/src/inflate/mod.rs b/vendor/miniz_oxide/src/inflate/mod.rs index 535392327..03b9dc988 100644 --- a/vendor/miniz_oxide/src/inflate/mod.rs +++ b/vendor/miniz_oxide/src/inflate/mod.rs @@ -151,14 +151,12 @@ fn decompress_to_vec_inner( } TINFLStatus::HasMoreOutput => { - // We need more space, so check if we can resize the buffer and do it. - let new_len = ret - .len() - .checked_add(out_pos) - .ok_or(TINFLStatus::HasMoreOutput)?; - if new_len > max_output_size { + // if the buffer has already reached the size limit, return an error + if ret.len() >= max_output_size { return Err(TINFLStatus::HasMoreOutput); - }; + } + // calculate the new length, capped at `max_output_size` + let new_len = ret.len().saturating_mul(2).min(max_output_size); ret.resize(new_len, 0); } -- cgit v1.2.3