From 3710b23db5aef20a9f6159908791fb3840459d34 Mon Sep 17 00:00:00 2001 From: Christian Ebner Date: Mon, 9 Sep 2019 18:27:30 +0200 Subject: [PATCH] src/pxar/decoder.rs: read_link has to read filename before entry. The offset points to the start of the item, which is the filename Signed-off-by: Christian Ebner --- src/pxar/decoder.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pxar/decoder.rs b/src/pxar/decoder.rs index aca74935..9db26e21 100644 --- a/src/pxar/decoder.rs +++ b/src/pxar/decoder.rs @@ -371,8 +371,13 @@ impl Result<(), Error>> Decoder { /// Read the target of a hardlink in the archive. pub fn read_link(&mut self, offset: u64) -> Result<(PathBuf, PxarEntry), Error> { self.seek(SeekFrom::Start(offset))?; - let mut 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)?; + + header = self.inner.read_item()?; check_ca_header::(&header, PXAR_ENTRY)?; let entry: PxarEntry = self.inner.read_item()?;