From 866516ac50851e2827e6aff0a98c444268c566ff Mon Sep 17 00:00:00 2001 From: igorechek06 Date: Sat, 10 Aug 2024 17:18:03 +0900 Subject: Add overlap checking --- src/zip/error.rs | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src/zip/error.rs') diff --git a/src/zip/error.rs b/src/zip/error.rs index 87cd9e9..dbb6bb5 100644 --- a/src/zip/error.rs +++ b/src/zip/error.rs @@ -9,9 +9,11 @@ pub enum ZipError { Io(IoError), EocdrNotFound, - InvalidEOCDR64Signature, + InvalidEocdr64Signature, InvalidFileHeaderSignature, - InvalidCDRSignature, + InvalidCdrSignature, + + Overlapping(&'static str, &'static str), UnsupportedCompressionMethod(u16), UnsupportedEncryptionMethod, @@ -53,8 +55,9 @@ impl Display for ZipError { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { Self::Io(error) => write!(f, "{}", error), + Self::EocdrNotFound => write!(f, "End of central directory record not found"), - Self::InvalidEOCDR64Signature => { + Self::InvalidEocdr64Signature => { write!( f, "Invalid signature of zip64 end of central directory record" @@ -63,12 +66,16 @@ impl Display for ZipError { Self::InvalidFileHeaderSignature => { write!(f, "Invalid file header signature") } - Self::InvalidCDRSignature => { + Self::InvalidCdrSignature => { write!(f, "Invalid signature of central directory record") } + Self::Overlapping(struct1, struct2) => { + write!(f, "`{}` overlapt `{}`", struct1, struct2) + } + Self::UnsupportedCompressionMethod(id) => { - writeln!(f, "Unsupported compression method {}", id) + writeln!(f, "Unsupported compression method `{}`", id) } Self::UnsupportedEncryptionMethod => { writeln!(f, "Unsupported encryption method") -- cgit v1.2.3