src/pxar/decoder.rs: fix bug in decoder read

`offset` points to the `PXAR_FILENAME`, therefore read the filename before
the `PXAR_ENTRY`.

Signed-off-by: Christian Ebner <c.ebner@proxmox.com>
This commit is contained in:
Christian Ebner 2019-09-16 16:59:31 +02:00 committed by Dietmar Maurer
parent 2aba16bde1
commit 1c93182371
1 changed files with 5 additions and 0 deletions

View File

@ -345,6 +345,11 @@ impl<R: Read + Seek, F: Fn(&Path) -> Result<(), Error>> Decoder<R, F> {
/// returned.
pub fn read(&mut self, offset: u64, size: usize, data_offset: u64) -> Result<Vec<u8>, Error> {
self.seek(SeekFrom::Start(offset))?;
let head: PxarHeader = self.inner.read_item()?;
if head.htype != PXAR_FILENAME {
bail!("Expected PXAR_FILENAME, encountered 0x{:x?}", head.htype);
}
let _filename = self.inner.read_filename(head.size)?;
let head: PxarHeader = self.inner.read_item()?;
check_ca_header::<PxarEntry>(&head, PXAR_ENTRY)?;