From fb2554de296c48abdc610fd86bcc2f0b56500b89 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Tue, 5 Nov 2019 17:02:53 +0100 Subject: [PATCH] src/pxar/decoder.rs: fix wrong filename check for Decoder::restore() As it turns out the original implementation was correct and the start in `DirectoryEntry` points to the `PxarEntry` and not as wrongly stated to the filename. This reverts the incorrect code and adds comments to the fields clarifying this. Signed-off-by: Christian Ebner --- src/pxar/decoder.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index a319346d..bc0b7f46 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -17,7 +17,9 @@ use super::match_pattern::MatchPattern; use proxmox::tools::io::ReadExt; pub struct DirectoryEntry { + /// Points to the `PxarEntry` of the directory start: u64, + /// Points past the goodbye table tail end: u64, pub filename: OsString, pub entry: PxarEntry, @@ -73,16 +75,6 @@ impl Result<(), Error>> Decoder { pub fn restore(&mut self, dir: &DirectoryEntry, path: &Path, pattern: &Vec) -> Result<(), Error> { let start = dir.start; 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, pattern)?; Ok(())