test: Fix failing test: kind tag was being read twice
This commit is contained in:
parent
b635a7d7e3
commit
d91e9ff436
1 changed files with 4 additions and 3 deletions
|
@ -306,7 +306,7 @@ impl ExtendedFileOptions {
|
||||||
Arc::get_mut(field).unwrap()
|
Arc::get_mut(field).unwrap()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
vec.reserve_exact(data.len() + 4);
|
vec.reserve_exact(len);
|
||||||
vec.write_u16_le(header_id)?;
|
vec.write_u16_le(header_id)?;
|
||||||
vec.write_u16_le(data.len() as u16)?;
|
vec.write_u16_le(data.len() as u16)?;
|
||||||
vec.write_all(&data)?;
|
vec.write_all(&data)?;
|
||||||
|
@ -327,10 +327,10 @@ impl ExtendedFileOptions {
|
||||||
}
|
}
|
||||||
let mut data = Cursor::new(data);
|
let mut data = Cursor::new(data);
|
||||||
while data.position() < len {
|
while data.position() < len {
|
||||||
if len - data.position() < 2 {
|
if len - data.position() < 4 {
|
||||||
return Err(ZipError::Io(io::Error::new(
|
return Err(ZipError::Io(io::Error::new(
|
||||||
io::ErrorKind::Other,
|
io::ErrorKind::Other,
|
||||||
"Extra-data field needs 2 tag bytes",
|
"Extra-data field doesn't have room for tag and length",
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "unreserved"))]
|
#[cfg(not(feature = "unreserved"))]
|
||||||
|
@ -349,6 +349,7 @@ impl ExtendedFileOptions {
|
||||||
),
|
),
|
||||||
)));
|
)));
|
||||||
}
|
}
|
||||||
|
data.seek(SeekFrom::Current(-2))?;
|
||||||
}
|
}
|
||||||
parse_single_extra_field(&mut ZipFileData::default(), &mut data)?;
|
parse_single_extra_field(&mut ZipFileData::default(), &mut data)?;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue