diff options
| author | igorechek06 <me@igorek.dev> | 2024-08-10 17:18:03 +0900 |
|---|---|---|
| committer | igorechek06 <me@igorek.dev> | 2024-08-10 17:18:43 +0900 |
| commit | 866516ac50851e2827e6aff0a98c444268c566ff (patch) | |
| tree | 1134bf6f714d75a1050befa0f67bddd2d4b085c8 /src/zip/error.rs | |
| parent | 51f2737ca7af016e3dd3ad03673f48a754a1642e (diff) | |
| download | archivator-866516ac50851e2827e6aff0a98c444268c566ff.tar.gz archivator-866516ac50851e2827e6aff0a98c444268c566ff.zip | |
Add overlap checking
Diffstat (limited to 'src/zip/error.rs')
| -rw-r--r-- | src/zip/error.rs | 17 |
1 files changed, 12 insertions, 5 deletions
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 { | |||
| 9 | Io(IoError), | 9 | Io(IoError), |
| 10 | 10 | ||
| 11 | EocdrNotFound, | 11 | EocdrNotFound, |
| 12 | InvalidEOCDR64Signature, | 12 | InvalidEocdr64Signature, |
| 13 | InvalidFileHeaderSignature, | 13 | InvalidFileHeaderSignature, |
| 14 | InvalidCDRSignature, | 14 | InvalidCdrSignature, |
| 15 | |||
| 16 | Overlapping(&'static str, &'static str), | ||
| 15 | 17 | ||
| 16 | UnsupportedCompressionMethod(u16), | 18 | UnsupportedCompressionMethod(u16), |
| 17 | UnsupportedEncryptionMethod, | 19 | UnsupportedEncryptionMethod, |
| @@ -53,8 +55,9 @@ impl Display for ZipError { | |||
| 53 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | 55 | fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
| 54 | match self { | 56 | match self { |
| 55 | Self::Io(error) => write!(f, "{}", error), | 57 | Self::Io(error) => write!(f, "{}", error), |
| 58 | |||
| 56 | Self::EocdrNotFound => write!(f, "End of central directory record not found"), | 59 | Self::EocdrNotFound => write!(f, "End of central directory record not found"), |
| 57 | Self::InvalidEOCDR64Signature => { | 60 | Self::InvalidEocdr64Signature => { |
| 58 | write!( | 61 | write!( |
| 59 | f, | 62 | f, |
| 60 | "Invalid signature of zip64 end of central directory record" | 63 | "Invalid signature of zip64 end of central directory record" |
| @@ -63,12 +66,16 @@ impl Display for ZipError { | |||
| 63 | Self::InvalidFileHeaderSignature => { | 66 | Self::InvalidFileHeaderSignature => { |
| 64 | write!(f, "Invalid file header signature") | 67 | write!(f, "Invalid file header signature") |
| 65 | } | 68 | } |
| 66 | Self::InvalidCDRSignature => { | 69 | Self::InvalidCdrSignature => { |
| 67 | write!(f, "Invalid signature of central directory record") | 70 | write!(f, "Invalid signature of central directory record") |
| 68 | } | 71 | } |
| 69 | 72 | ||
| 73 | Self::Overlapping(struct1, struct2) => { | ||
| 74 | write!(f, "`{}` overlapt `{}`", struct1, struct2) | ||
| 75 | } | ||
| 76 | |||
| 70 | Self::UnsupportedCompressionMethod(id) => { | 77 | Self::UnsupportedCompressionMethod(id) => { |
| 71 | writeln!(f, "Unsupported compression method {}", id) | 78 | writeln!(f, "Unsupported compression method `{}`", id) |
| 72 | } | 79 | } |
| 73 | Self::UnsupportedEncryptionMethod => { | 80 | Self::UnsupportedEncryptionMethod => { |
| 74 | writeln!(f, "Unsupported encryption method") | 81 | writeln!(f, "Unsupported encryption method") |
