#3325·fresh

Rust 高亮错误

作者: asukaminato0721创建于 2026年9月19日更新于 2026年9月19日
标签bugreproduced

// 从 GARbro ArcWARC.cs 中移植,版权 (C) 2015-2017 morkt (MIT)。使用 anyhow::{Result, bail, ensure}。使用 std::io::Read。pub const MAX_OUTPUT: usize = 256 * 1024 * 1024; pub fn zlib(input: &[u8], limit: usize) -> Result<Vec<u8>> { ensure!(limit <= MAX_OUTPUT, "解压限制超出安全上限"); let mut output = Vec::new(); flate2::read::ZlibDecoder::new(input).take(limit as u64 + 1).read_to_end(&mut output)?; ensure!(output.len() <= limit, "zlib 输出超出限制 {limit}"); Ok(output) }