This commit is contained in:
Chris Hennick 2023-05-11 20:49:42 -07:00
parent 2e257141e6
commit 93a5be27ff
No known key found for this signature in database
GPG key ID: 25653935CC8B6C74

View file

@ -1037,11 +1037,10 @@ impl<W: Write + Seek> ZipWriter<W> {
#[cfg_attr(fuzzing, visibility::make(pub))]
#[cfg_attr(fuzzing, allow(missing_docs))]
pub(crate) fn validate_name(name: &String) -> ZipResult<()> {
let bytes = name.as_bytes();
for (index, _) in name.match_indices("PK") {
if name.len() >= index + 4 {
let magic_number = name[index..index + 4]
.as_bytes()
.read_u32::<LittleEndian>()?;
if bytes.len() >= index + 4 {
let magic_number = (&bytes[index..]).read_u32::<LittleEndian>()?;
match magic_number {
spec::ZIP64_CENTRAL_DIRECTORY_END_SIGNATURE => {
return Err(InvalidArchive("Filename can't contain ZIP64 end signature"));