5
0
mirror of git://git.proxmox.com/git/pxar.git synced 2025-01-31 09:47:00 +03:00

decoder: more hardlink reading fixups

the previous code use a read helper which would not allow
for there to be more data after the offset

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2020-06-05 14:00:06 +02:00
parent d67488626b
commit 28be6927ea

View File

@ -562,11 +562,17 @@ impl<I: SeqRead> DecoderImpl<I> {
}
async fn read_hardlink(&mut self) -> io::Result<format::Hardlink> {
let offset: u64 = self.read_simple_entry("hardlink offset").await?;
let size =
usize::try_from(self.current_header.content_size()).map_err(io_err_other)?
- size_of::<u64>();
let data = seq_read_exact_data(&mut self.input, size).await?;
let content_size =
usize::try_from(self.current_header.content_size()).map_err(io_err_other)?;
if content_size <= size_of::<u64>() {
io_bail!("bad hardlink entry (too small)");
}
let data_size = content_size - size_of::<u64>();
let offset: u64 = seq_read_entry(&mut self.input).await?;
let data = seq_read_exact_data(&mut self.input, data_size).await?;
Ok(format::Hardlink { offset, data })
}