@@ -465,44 +465,23 @@ def _decodeExtra(self):
465
465
if ln + 4 > len (extra ):
466
466
raise BadZipFile ("Corrupt extra field %04x (size=%d)" % (tp , ln ))
467
467
if tp == 0x0001 :
468
- if ln >= 24 :
469
- counts = unpack ('<QQQ' , extra [4 :28 ])
470
- elif ln == 16 :
471
- counts = unpack ('<QQ' , extra [4 :20 ])
472
- elif ln == 8 :
473
- counts = unpack ('<Q' , extra [4 :12 ])
474
- elif ln == 0 :
475
- counts = ()
476
- else :
477
- raise BadZipFile ("Corrupt extra field %04x (size=%d)" % (tp , ln ))
478
-
479
- idx = 0
480
-
468
+ data = extra [4 :ln + 4 ]
481
469
# ZIP64 extension (large files and/or large archives)
482
- if self .file_size in (0xffffffffffffffff , 0xffffffff ):
483
- if len (counts ) <= idx :
484
- raise BadZipFile (
485
- "Corrupt zip64 extra field. File size not found."
486
- )
487
- self .file_size = counts [idx ]
488
- idx += 1
489
-
490
- if self .compress_size == 0xFFFFFFFF :
491
- if len (counts ) <= idx :
492
- raise BadZipFile (
493
- "Corrupt zip64 extra field. Compress size not found."
494
- )
495
- self .compress_size = counts [idx ]
496
- idx += 1
497
-
498
- if self .header_offset == 0xffffffff :
499
- if len (counts ) <= idx :
500
- raise BadZipFile (
501
- "Corrupt zip64 extra field. Header offset not found."
502
- )
503
- old = self .header_offset
504
- self .header_offset = counts [idx ]
505
- idx += 1
470
+ try :
471
+ if self .file_size in (0xFFFF_FFFF_FFFF_FFFF , 0xFFFF_FFFF ):
472
+ field = "File size"
473
+ self .file_size , = unpack ('<Q' , data [:8 ])
474
+ data = data [8 :]
475
+ if self .compress_size == 0xFFFF_FFFF :
476
+ field = "Compress size"
477
+ self .compress_size , = unpack ('<Q' , data [:8 ])
478
+ data = data [8 :]
479
+ if self .header_offset == 0xFFFF_FFFF :
480
+ field = "Header offset"
481
+ self .header_offset , = unpack ('<Q' , data [:8 ])
482
+ except struct .error :
483
+ raise BadZipFile (f"Corrupt zip64 extra field. "
484
+ f"{ field } not found." ) from None
506
485
507
486
extra = extra [ln + 4 :]
508
487
0 commit comments