File tree Expand file tree Collapse file tree 1 file changed +12
-5
lines changed
Expand file tree Collapse file tree 1 file changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,9 @@ impl ExtendedTimestamp {
2121 R : Read ,
2222 {
2323 let mut flags = [ 0u8 ] ;
24+ let mut bytes_to_read = len as usize ;
2425 reader. read_exact ( & mut flags) ?;
26+ bytes_to_read -= flags. len ( ) ;
2527 let flags = flags[ 0 ] ;
2628
2729 // the `flags` field refers to the local headers and might not correspond
@@ -40,29 +42,34 @@ impl ExtendedTimestamp {
4042 ) ) ;
4143 }
4244
43- if flags & 0b11111000 != 0 {
44- return Err ( ZipError :: UnsupportedArchive (
45- "found unsupported timestamps in the extended timestamp header" ,
46- ) ) ;
47- }
45+ // allow unsupported/undocumented flags
4846
4947 let mod_time = if ( flags & 0b00000001u8 == 0b00000001u8 ) || len == 5 {
48+ bytes_to_read -= size_of :: < u32 > ( ) ;
5049 Some ( reader. read_u32_le ( ) ?)
5150 } else {
5251 None
5352 } ;
5453
5554 let ac_time = if flags & 0b00000010u8 == 0b00000010u8 && len > 5 {
55+ bytes_to_read -= size_of :: < u32 > ( ) ;
5656 Some ( reader. read_u32_le ( ) ?)
5757 } else {
5858 None
5959 } ;
6060
6161 let cr_time = if flags & 0b00000100u8 == 0b00000100u8 && len > 5 {
62+ bytes_to_read -= size_of :: < u32 > ( ) ;
6263 Some ( reader. read_u32_le ( ) ?)
6364 } else {
6465 None
6566 } ;
67+
68+ if bytes_to_read > 0 {
69+ // ignore undocumented bytes
70+ reader. read_exact ( & mut vec ! [ 0 ; bytes_to_read] ) ?
71+ }
72+
6673 Ok ( Self {
6774 mod_time,
6875 ac_time,
You can’t perform that action at this time.
0 commit comments