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:
parent
58262f40f7
commit
e5471b4836
@ -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()?;
|
||||
|
||||
|
@ -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.");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user