aboutsummaryrefslogtreecommitdiff
path: root/src/zip/driver.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/zip/driver.rs')
-rw-r--r--src/zip/driver.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/zip/driver.rs b/src/zip/driver.rs
index 9dccfd0..81629dd 100644
--- a/src/zip/driver.rs
+++ b/src/zip/driver.rs
@@ -83,11 +83,11 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
83 + io.read_vec( 83 + io.read_vec(
84 (limit as usize) 84 (limit as usize)
85 .checked_sub(18) 85 .checked_sub(18)
86 .ok_or(ZipError::EocdrNotFound)?, 86 .ok_or(ZipError::StructNotFound("Eocdr"))?,
87 )? 87 )?
88 .windows(4) 88 .windows(4)
89 .rposition(|v| v == EOCDR_SIGNATURE) 89 .rposition(|v| v == EOCDR_SIGNATURE)
90 .ok_or(ZipError::EocdrNotFound)? as u64; 90 .ok_or(ZipError::StructNotFound("Eocdr"))? as u64;
91 91
92 // Read eocdr 92 // Read eocdr
93 io.seek(SeekFrom::Start(pos + 4))?; 93 io.seek(SeekFrom::Start(pos + 4))?;
@@ -106,7 +106,7 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
106 io.seek(SeekFrom::Start(eocdr64locator.eocdr64_pointer))?; 106 io.seek(SeekFrom::Start(eocdr64locator.eocdr64_pointer))?;
107 let buf = io.read_arr::<56>()?; 107 let buf = io.read_arr::<56>()?;
108 if buf[0..4] != EOCDR64_SIGNATURE { 108 if buf[0..4] != EOCDR64_SIGNATURE {
109 return Err(ZipError::InvalidEocdr64Signature); 109 return Err(ZipError::InvalidSignature("Eocdr64"));
110 } 110 }
111 let eocdr64: Eocdr64 = deserialize(&buf[4..]).unwrap(); 111 let eocdr64: Eocdr64 = deserialize(&buf[4..]).unwrap();
112 if eocdr64.cd_pointer + eocdr64.cd_size > eocdr64locator.eocdr64_pointer { 112 if eocdr64.cd_pointer + eocdr64.cd_size > eocdr64locator.eocdr64_pointer {
@@ -139,14 +139,14 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
139 let buf = cd_reader.read_arr::<46>()?; 139 let buf = cd_reader.read_arr::<46>()?;
140 140
141 if buf[..4] != CDR_SIGNATURE { 141 if buf[..4] != CDR_SIGNATURE {
142 return Err(ZipError::InvalidCdrSignature); 142 return Err(ZipError::InvalidSignature("Cdr"));
143 } 143 }
144 let cdr: Cdr = deserialize(&buf[4..46]).unwrap(); 144 let cdr: Cdr = deserialize(&buf[4..46]).unwrap();
145 let bit_flag = BitFlag::new(cdr.bit_flag); 145 let bit_flag = BitFlag::new(cdr.bit_flag);
146 146
147 let name = cd_reader.read_vec(cdr.name_len as usize)?; 147 let name = cd_reader.read_vec(cdr.name_len as usize)?;
148 let name = if bit_flag.is_utf8() { 148 let name = if bit_flag.is_utf8() {
149 String::from_utf8(name).map_err(|_| ZipError::InvalidFileName)? 149 String::from_utf8(name).map_err(|_| ZipError::InvalidField("file_name"))?
150 } else { 150 } else {
151 String::from_cp437(name) 151 String::from_cp437(name)
152 }; 152 };
@@ -155,7 +155,7 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
155 155
156 let comment = cd_reader.read_vec(cdr.comment_len as usize)?; 156 let comment = cd_reader.read_vec(cdr.comment_len as usize)?;
157 let comment = if bit_flag.is_utf8() { 157 let comment = if bit_flag.is_utf8() {
158 String::from_utf8(comment).map_err(|_| ZipError::InvalidFileComment)? 158 String::from_utf8(comment).map_err(|_| ZipError::InvalidField("file_comment"))?
159 } else { 159 } else {
160 String::from_cp437(comment) 160 String::from_cp437(comment)
161 }; 161 };
@@ -216,7 +216,7 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
216 0x9901 => { 216 0x9901 => {
217 let aes: AesField = deserialize(&data.read_arr::<7>()?).unwrap(); 217 let aes: AesField = deserialize(&data.read_arr::<7>()?).unwrap();
218 if aes.id != [0x41, 0x45] { 218 if aes.id != [0x41, 0x45] {
219 return Err(ZipError::InvalidExtraFields); 219 return Err(ZipError::InvalidField("extra_fields"));
220 } 220 }
221 encryption_method = match aes.strength { 221 encryption_method = match aes.strength {
222 0x01 => EncryptionMethod::Aes128, 222 0x01 => EncryptionMethod::Aes128,
@@ -232,7 +232,7 @@ impl<Io: Read + Seek> ArchiveRead for Zip<Io> {
232 } 232 }
233 233
234 if compression_method == 99 { 234 if compression_method == 99 {
235 return Err(ZipError::AesExtraFieldNotFound); 235 return Err(ZipError::StructNotFound("AesExtensibleData"));
236 } 236 }
237 237
238 indexes.insert(name.clone(), i); 238 indexes.insert(name.clone(), i);