From 5e8d600c7103f5522b4c2764f0f883cd29494010 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 5 Nov 2019 13:45:03 +0100 Subject: [PATCH] src/pxar/decoder.rs: fix issue with restore `Decoder::restore()` calls the `SequentialDecoder::restore()` which expects to encounter a `PxarEntry` at first. But the start of `DirectoryEntry` points to the filename (except for the root dir), so skip over it. Signed-off-by: Christian Ebner --- src/pxar/decoder.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index e38b8afb..34f59ca1 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -70,6 +70,16 @@ impl Result<(), Error>> Decoder { self.seek(SeekFrom::Start(start))?; + // Except for the root dir, `DirectoryEntry` start points to the filename. + // But `SequentialDecoder::restore()` expects the entry point to be of + // type `PxarEntry`, so lets skip over the filename here if present. + if start != 0 { + let header: PxarHeader = self.inner.read_item()?; + if header.htype != PXAR_FILENAME { + bail!("Expected PXAR_FILENAME, encountered 0x{:x?}", header.htype); + } + let _filename = self.inner.read_filename(header.size)?; + } self.inner.restore(path, &Vec::new())?; Ok(())