Skip to content

Commit b0ae948

Browse files
committed
Work around ruzstd only decoding a single frame of the zstd data.
lld chunks the data into 1MB frames for parallel compression so almost everything will have multiple frames.
1 parent d6ab680 commit b0ae948

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/symbolize/gimli/elf.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -357,11 +357,26 @@ fn decompress_zlib(input: &[u8], output: &mut [u8]) -> Option<()> {
357357
}
358358
}
359359

360-
fn decompress_zstd(input: &[u8], output: &mut [u8]) -> Option<()> {
360+
fn decompress_zstd(mut input: &[u8], mut output: &mut [u8]) -> Option<()> {
361361
use ruzstd::io::Read;
362362

363-
let mut decoder = ruzstd::StreamingDecoder::new(input).ok()?;
364-
decoder.read_exact(output).ok()
363+
while !input.is_empty() {
364+
let mut decoder = ruzstd::StreamingDecoder::new(&mut input).ok()?;
365+
loop {
366+
let bytes_written = decoder.read(output).ok()?;
367+
if bytes_written == 0 {
368+
break;
369+
}
370+
output = &mut output[bytes_written..];
371+
}
372+
}
373+
374+
if !output.is_empty() {
375+
// Lengths didn't match, something is wrong.
376+
return None;
377+
}
378+
379+
Some(())
365380
}
366381

367382
const DEBUG_PATH: &[u8] = b"/usr/lib/debug";

0 commit comments

Comments
 (0)