pxar/decoder: avoid failing on hardlinks and return corresponding target file entry

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
[Fixup: remove unnecessary 'mut']
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Christian Ebner 2019-08-20 13:40:19 +02:00 committed by Wolfgang Bumiller
parent 58262f40f7
commit e5471b4836
2 changed files with 5 additions and 1 deletions

View File

@ -90,6 +90,10 @@ impl <R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<R, F> {
let filename = self.inner.read_filename(head.size)?;
let head: PxarHeader = self.inner.read_item()?;
if head.htype == PXAR_FORMAT_HARDLINK {
let (_, offset) = self.inner.read_hardlink(head.size)?;
return self.read_directory_entry(start - offset, end);
}
check_ca_header::<PxarEntry>(&head, PXAR_ENTRY)?;
let entry: PxarEntry = self.inner.read_item()?;

View File

@ -99,7 +99,7 @@ impl <R: Read, F: Fn(&Path) -> Result<(), Error>> SequentialDecoder<R, F> {
Ok(PathBuf::from(std::ffi::OsString::from_vec(buffer)))
}
fn read_hardlink(&mut self, size: u64) -> Result<(PathBuf, u64), Error> {
pub (crate) fn read_hardlink(&mut self, size: u64) -> Result<(PathBuf, u64), Error> {
if size < (HEADER_SIZE + 8 + 2) {
bail!("dectected short hardlink header.");
}