File tree Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Expand file tree Collapse file tree 1 file changed +18
-3
lines changed Original file line number Diff line number Diff 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
367382const DEBUG_PATH : & [ u8 ] = b"/usr/lib/debug" ;
You can’t perform that action at this time.
0 commit comments