Bug fix
This commit is contained in:
parent
93a5be27ff
commit
5a11cbeaee
1 changed files with 13 additions and 13 deletions
|
@ -1038,9 +1038,10 @@ impl<W: Write + Seek> ZipWriter<W> {
|
||||||
#[cfg_attr(fuzzing, allow(missing_docs))]
|
#[cfg_attr(fuzzing, allow(missing_docs))]
|
||||||
pub(crate) fn validate_name(name: &String) -> ZipResult<()> {
|
pub(crate) fn validate_name(name: &String) -> ZipResult<()> {
|
||||||
let bytes = name.as_bytes();
|
let bytes = name.as_bytes();
|
||||||
for (index, _) in name.match_indices("PK") {
|
let mut current_window = [0u8; 4];
|
||||||
if bytes.len() >= index + 4 {
|
for window in bytes.windows(4) {
|
||||||
let magic_number = (&bytes[index..]).read_u32::<LittleEndian>()?;
|
current_window.copy_from_slice(window);
|
||||||
|
let magic_number = u32::from_le_bytes(current_window);
|
||||||
match magic_number {
|
match magic_number {
|
||||||
spec::ZIP64_CENTRAL_DIRECTORY_END_SIGNATURE => {
|
spec::ZIP64_CENTRAL_DIRECTORY_END_SIGNATURE => {
|
||||||
return Err(InvalidArchive("Filename can't contain ZIP64 end signature"));
|
return Err(InvalidArchive("Filename can't contain ZIP64 end signature"));
|
||||||
|
@ -1053,7 +1054,6 @@ pub(crate) fn validate_name(name: &String) -> ZipResult<()> {
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue