From 9722dd31e9f54873d11c85820d25b5ee344bc89a Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Fri, 24 May 2024 12:57:34 -0700 Subject: [PATCH] Return error if file comment is too long Signed-off-by: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> --- src/spec.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/spec.rs b/src/spec.rs index 7dc8286f..d4c61113 100644 --- a/src/spec.rs +++ b/src/spec.rs @@ -264,7 +264,7 @@ impl Zip32CentralDirectoryEnd { number_of_files, central_directory_size, central_directory_offset, - zip_file_comment_length: zip_file_comment.len().try_into().unwrap_or(u16::MAX), + zip_file_comment_length: zip_file_comment.len().try_into().map_err(|_| ZipError::InvalidArchive("File comment must be less than 64 KiB"))?, }; Ok((block, zip_file_comment)) }