Skip to content

Commit

Permalink
Work around ruzstd only decoding a single frame of the zstd data.
Browse files Browse the repository at this point in the history
lld chunks the data into 1MB frames for parallel compression so almost
everything will have multiple frames.
  • Loading branch information
khuey committed Sep 13, 2024
1 parent d6ab680 commit b0ae948
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/symbolize/gimli/elf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,26 @@ fn decompress_zlib(input: &[u8], output: &mut [u8]) -> Option<()> {
}
}

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

let mut decoder = ruzstd::StreamingDecoder::new(input).ok()?;
decoder.read_exact(output).ok()
while !input.is_empty() {
let mut decoder = ruzstd::StreamingDecoder::new(&mut input).ok()?;
loop {
let bytes_written = decoder.read(output).ok()?;
if bytes_written == 0 {
break;
}
output = &mut output[bytes_written..];
}
}

if !output.is_empty() {
// Lengths didn't match, something is wrong.
return None;
}

Some(())
}

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

0 comments on commit b0ae948

Please sign in to comment.