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<R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<R, F> { 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(())