| 1 | package IO::Uncompress::Unzip; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # for RFC1952 | ||||||||||||||||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||||||||||||||||
| 4 | 83 | ▶ | use strict ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 83 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 83 | ▶ | use bytes; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 83 | ▶ | use IO::File; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 83 | ▶ | use IO::Uncompress::RawInflate 2.225 ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 83 | ▶ | use IO::Compress::Base::Common 2.225 qw(:Status ); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 83 | ▶ | use IO::Uncompress::Adapter::Inflate 2.225 ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 83 | ▶ | use IO::Uncompress::Adapter::Identity 2.225 ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 83 | ▶ | use IO::Compress::Zlib::Extra 2.225 ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 83 | ▶ | use IO::Compress::Zip::Constants 2.225 ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 83 | ▶ | use Compress::Raw::Zlib 2.225 () ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | BEGIN | ||||||||||||||||||||||||||||||||||||||||||
| 19 | 83 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.1
| |||||||||||||||||||||||||||||||||||||||||||
| 20 | # Don't trigger any __DIE__ Hooks. | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 83 | local $SIG{__DIE__}; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 83 | eval{ require IO::Uncompress::Adapter::Bunzip2 ; | |||||||||||||||||||||||||||||||||||||||||
| 24 | 83 | IO::Uncompress::Adapter::Bunzip2->VERSION(2.225) } ; | |||||||||||||||||||||||||||||||||||||||||
| 25 | 83 | eval{ require IO::Uncompress::Adapter::UnLzma ; | |||||||||||||||||||||||||||||||||||||||||
| 26 | 0 | IO::Uncompress::Adapter::UnLzma->VERSION(2.225) } ; | |||||||||||||||||||||||||||||||||||||||||
| 27 | 83 | eval{ require IO::Uncompress::Adapter::UnXz ; | |||||||||||||||||||||||||||||||||||||||||
| 28 | 0 | IO::Uncompress::Adapter::UnXz->VERSION(2.225) } ; | |||||||||||||||||||||||||||||||||||||||||
| 29 | 83 | eval{ require IO::Uncompress::Adapter::UnZstd ; | |||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | IO::Uncompress::Adapter::UnZstd->VERSION(2.225) } ; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||||||||||||||||
| 34 | 83 | require Exporter ; | |||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||
| 36 | 83 | our ($VERSION, @ISA, @EXPORT_OK, %EXPORT_TAGS, $UnzipError, %headerLookup); | |||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||
| 38 | 83 | $VERSION = '2.225'; | |||||||||||||||||||||||||||||||||||||||||
| 39 | 83 | $UnzipError = ''; | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 83 | @ISA = qw(IO::Uncompress::RawInflate Exporter); | |||||||||||||||||||||||||||||||||||||||||
| 42 | 83 | @EXPORT_OK = qw($UnzipError unzip ); | |||||||||||||||||||||||||||||||||||||||||
| 43 | 83 | %EXPORT_TAGS = %IO::Uncompress::RawInflate::EXPORT_TAGS ; | |||||||||||||||||||||||||||||||||||||||||
| 44 | 83 | ▶ | $EXPORT_TAGS{all} = [ defined $EXPORT_TAGS{all} ? @{ $EXPORT_TAGS{all} } : (), @EXPORT_OK ] ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 83 | Exporter::export_ok_tags('all'); | |||||||||||||||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||||||||||||||||
| 47 | 83 | %headerLookup = ( | |||||||||||||||||||||||||||||||||||||||||
| 48 | ZIP_CENTRAL_HDR_SIG, \&skipCentralDirectory, | ||||||||||||||||||||||||||||||||||||||||||
| 49 | ZIP_END_CENTRAL_HDR_SIG, \&skipEndCentralDirectory, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | ZIP64_END_CENTRAL_REC_HDR_SIG, \&skipCentralDirectory64Rec, | ||||||||||||||||||||||||||||||||||||||||||
| 51 | ZIP64_END_CENTRAL_LOC_HDR_SIG, \&skipCentralDirectory64Loc, | ||||||||||||||||||||||||||||||||||||||||||
| 52 | ZIP64_ARCHIVE_EXTRA_SIG, \&skipArchiveExtra, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | ZIP64_DIGITAL_SIGNATURE_SIG, \&skipDigitalSignature, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||||||||||||
| 56 | 83 | my %MethodNames = ( | |||||||||||||||||||||||||||||||||||||||||
| 57 | ZIP_CM_DEFLATE() => 'Deflated', | ||||||||||||||||||||||||||||||||||||||||||
| 58 | ZIP_CM_BZIP2() => 'Bzip2', | ||||||||||||||||||||||||||||||||||||||||||
| 59 | ZIP_CM_LZMA() => 'Lzma', | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ZIP_CM_STORE() => 'Stored', | ||||||||||||||||||||||||||||||||||||||||||
| 61 | ZIP_CM_XZ() => 'Xz', | ||||||||||||||||||||||||||||||||||||||||||
| 62 | ZIP_CM_ZSTD() => 'Zstd', | ||||||||||||||||||||||||||||||||||||||||||
| 63 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||||||||||||||||
| 65 | sub new | ||||||||||||||||||||||||||||||||||||||||||
| 66 | 315 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 67 | 315 | my $class = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 68 | 315 | my $obj = IO::Compress::Base::Common::createSelfTiedObject($class, \$UnzipError); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 315 | $obj->_create(undef, 0, @_); | |||||||||||||||||||||||||||||||||||||||||
| 70 | } | ||||||||||||||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||||||||||||
| 72 | sub unzip | ||||||||||||||||||||||||||||||||||||||||||
| 73 | 172 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unzip: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | 172 | my $obj = IO::Compress::Base::Common::createSelfTiedObject(undef, \$UnzipError); | |||||||||||||||||||||||||||||||||||||||||
| 75 | 172 | return $obj->_inf(@_) ; | |||||||||||||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | sub getExtraParams | ||||||||||||||||||||||||||||||||||||||||||
| 79 | 470 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
getExtraParams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | return ( | ||||||||||||||||||||||||||||||||||||||||||
| 82 | # # Zip header fields | ||||||||||||||||||||||||||||||||||||||||||
| 83 | 470 | 'name' => [IO::Compress::Base::Common::Parse_any, undef], | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 'stream' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||||||||||||||||||||||||||||||||||||||||
| 86 | 'efs' => [IO::Compress::Base::Common::Parse_boolean, 0], | ||||||||||||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||||||||||||
| 88 | # TODO - This means reading the central directory to get | ||||||||||||||||||||||||||||||||||||||||||
| 89 | # 1. the local header offsets | ||||||||||||||||||||||||||||||||||||||||||
| 90 | # 2. The compressed data length | ||||||||||||||||||||||||||||||||||||||||||
| 91 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | sub ckParams | ||||||||||||||||||||||||||||||||||||||||||
| 95 | 478 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ckParams: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 478 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 97 | 478 | my $got = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | # unzip always needs crc32 | ||||||||||||||||||||||||||||||||||||||||||
| 100 | 478 | $got->setValue('crc32' => 1); | |||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 478 | *$self->{UnzipData}{Name} = $got->getValue('name'); | |||||||||||||||||||||||||||||||||||||||||
| 103 | 478 | *$self->{UnzipData}{efs} = $got->getValue('efs'); | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 478 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||||||||||||
| 108 | sub mkUncomp | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 477 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
mkUncomp: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 477 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 111 | 477 | my $got = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | 477 | ▶ | my $magic = $self->ckMagic() | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||
| 115 | |||||||||||||||||||||||||||||||||||||||||||
| 116 | 423 | ▶ | *$self->{Info} = $self->readHeader($magic) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 117 | or return undef ; | ||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | 420 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 120 | |||||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | sub ckMagic | ||||||||||||||||||||||||||||||||||||||||||
| 124 | 1389 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ckMagic: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | 1389 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 1389 | my $magic ; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 1389 | $self->smartReadExact(\$magic, 4); | |||||||||||||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||||||||||||
| 130 | 1389 | *$self->{HeaderPending} = $magic ; | |||||||||||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||||||||||||
| 132 | 1389 | ▶ | return $self->HeaderError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | 4 . " bytes") | ||||||||||||||||||||||||||||||||||||||||||
| 134 | if length $magic != 4 ; | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | 1342 | ▶ | return $self->HeaderError("Bad Magic") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | if ! _isZipMagic($magic) ; | ||||||||||||||||||||||||||||||||||||||||||
| 138 | |||||||||||||||||||||||||||||||||||||||||||
| 139 | 1018 | *$self->{Type} = 'zip'; | |||||||||||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||||||||||||
| 141 | 1018 | return $magic ; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } | ||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||
| 144 | |||||||||||||||||||||||||||||||||||||||||||
| 145 | sub fastForward | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 60 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fastForward: called CC=4 SCAR=14.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | 60 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 148 | 60 | my $offset = shift; | |||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | # TODO - if Stream isn't enabled & reading from file, use seek | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 60 | my $buffer = ''; | |||||||||||||||||||||||||||||||||||||||||
| 153 | 60 | my $c = 1024 * 16; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 60 | ▶ | while ($offset > 0) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | { | ||||||||||||||||||||||||||||||||||||||||||
| 157 | 42 | ▶ | $c = $offset | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | if $offset < $c ; | ||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 42 | $offset -= $c; | |||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 42 | ▶ | $self->smartReadExact(\$buffer, $c) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | or return 0; | ||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 60 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 167 | } | ||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||||||||||||
| 170 | sub readHeader | ||||||||||||||||||||||||||||||||||||||||||
| 171 | 1018 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readHeader: called CC=12 SCAR=25.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 1018 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 1018 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 1018 | my $name = *$self->{UnzipData}{Name} ; | |||||||||||||||||||||||||||||||||||||||||
| 176 | 1018 | my $hdr = $self->_readZipHeader($magic) ; | |||||||||||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||||||||||||
| 178 | 1017 | ▶ | while (defined $hdr) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | { | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 1052 | ▶ | if (! defined $name || $hdr->{Name} eq $name) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
not defined $name or $hdr->{"Name"} eq $name
MC/DC100%2/2
not defined $name or $hdr->{"Name"} eq $name
not defined $name
$hdr->{"Name"} eq $name
Truth table100%3/3
not(A) or B
A= not defined $nameB= $hdr->{"Name"} eq $name
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | { | ||||||||||||||||||||||||||||||||||||||||||
| 182 | 1015 | return $hdr ; | |||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||
| 185 | # skip the data | ||||||||||||||||||||||||||||||||||||||||||
| 186 | # TODO - when Stream is off, use seek | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 37 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 188 | 37 | ▶ | if (*$self->{ZipData}{Streaming}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 11 | while (1) { | |||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | 12 | my $b; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 12 | my $status = $self->smartRead(\$b, 1024 * 16); | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 12 | ▶ | return $self->saveErrorString(undef, "Truncated file") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | if $status <= 0 ; | ||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||
| 197 | 12 | my $temp_buf ; | |||||||||||||||||||||||||||||||||||||||||
| 198 | my $out; | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | 12 | $status = *$self->{Uncomp}->uncompr(\$b, \$temp_buf, 0, $out); | |||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | return $self->saveErrorString(undef, *$self->{Uncomp}{Error}, | ||||||||||||||||||||||||||||||||||||||||||
| 203 | *$self->{Uncomp}{ErrorNo}) | ||||||||||||||||||||||||||||||||||||||||||
| 204 | 12 | ▶ | if $self->saveStatus($status) == STATUS_ERROR; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 12 | $self->pushBack($b) ; | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 12 | ▶ | if ($status == STATUS_ENDSTREAM) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 11 | *$self->{Uncomp}->reset(); | |||||||||||||||||||||||||||||||||||||||||
| 210 | 11 | last; | |||||||||||||||||||||||||||||||||||||||||
| 211 | } | ||||||||||||||||||||||||||||||||||||||||||
| 212 | } | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | # skip the trailer | ||||||||||||||||||||||||||||||||||||||||||
| 215 | $self->smartReadExact(\$buffer, $hdr->{TrailerLength}) | ||||||||||||||||||||||||||||||||||||||||||
| 216 | 11 | ▶ | or return $self->saveErrorString(undef, "Truncated file"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 26 | my $c = $hdr->{CompressedLength}->get64bit(); | |||||||||||||||||||||||||||||||||||||||||
| 220 | 26 | ▶ | $self->fastForward($c) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 221 | or return $self->saveErrorString(undef, "Truncated file"); | ||||||||||||||||||||||||||||||||||||||||||
| 222 | 26 | $buffer = ''; | |||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | 37 | ▶ | $self->chkTrailer($buffer) == STATUS_OK | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 226 | or return $self->saveErrorString(undef, "Truncated file"); | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | 37 | $hdr = $self->_readFullZipHeader(); | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 37 | ▶ | return $self->saveErrorString(undef, "Cannot find '$name'") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 231 | if $self->smartEof(); | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||
| 234 | 2 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | sub chkTrailer | ||||||||||||||||||||||||||||||||||||||||||
| 238 | 1041 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
chkTrailer: called CC=18 SCAR=33.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 1041 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 1041 | my $trailer = shift; | |||||||||||||||||||||||||||||||||||||||||
| 241 | |||||||||||||||||||||||||||||||||||||||||||
| 242 | 1041 | my ($sig, $CRC32, $cSize, $uSize) ; | |||||||||||||||||||||||||||||||||||||||||
| 243 | 1041 | my ($cSizeHi, $uSizeHi) = (0, 0); | |||||||||||||||||||||||||||||||||||||||||
| 244 | 1041 | ▶ | if (*$self->{ZipData}{Streaming}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 245 | 939 | $sig = unpack ("V", substr($trailer, 0, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 939 | $CRC32 = unpack ("V", substr($trailer, 4, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | 939 | ▶ | if (*$self->{ZipData}{Zip64} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 249 | 31 | $cSize = U64::newUnpack_V64 substr($trailer, 8, 8); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 31 | $uSize = U64::newUnpack_V64 substr($trailer, 16, 8); | |||||||||||||||||||||||||||||||||||||||||
| 251 | } | ||||||||||||||||||||||||||||||||||||||||||
| 252 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 253 | 908 | $cSize = U64::newUnpack_V32 substr($trailer, 8, 4); | |||||||||||||||||||||||||||||||||||||||||
| 254 | 908 | $uSize = U64::newUnpack_V32 substr($trailer, 12, 4); | |||||||||||||||||||||||||||||||||||||||||
| 255 | } | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 939 | ▶ | return $self->TrailerError("Data Descriptor signature, got $sig") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | if $sig != ZIP_DATA_HDR_SIG; | ||||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 261 | ($CRC32, $cSize, $uSize) = | ||||||||||||||||||||||||||||||||||||||||||
| 262 | (*$self->{ZipData}{Crc32}, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | *$self->{ZipData}{CompressedLen}, | ||||||||||||||||||||||||||||||||||||||||||
| 264 | 102 | *$self->{ZipData}{UnCompressedLen}); | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 1039 | *$self->{Info}{CRC32} = *$self->{ZipData}{CRC32} ; | |||||||||||||||||||||||||||||||||||||||||
| 268 | 1039 | *$self->{Info}{CompressedLength} = $cSize->get64bit(); | |||||||||||||||||||||||||||||||||||||||||
| 269 | 1039 | *$self->{Info}{UncompressedLength} = $uSize->get64bit(); | |||||||||||||||||||||||||||||||||||||||||
| 270 | |||||||||||||||||||||||||||||||||||||||||||
| 271 | 1039 | ▶ | if (*$self->{Strict}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 272 | return $self->TrailerError("CRC mismatch") | ||||||||||||||||||||||||||||||||||||||||||
| 273 | 489 | ▶ | if $CRC32 != *$self->{ZipData}{CRC32} ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | return $self->TrailerError("CSIZE mismatch.") | ||||||||||||||||||||||||||||||||||||||||||
| 276 | 489 | ▶ | if ! $cSize->equal(*$self->{CompSize}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | return $self->TrailerError("USIZE mismatch.") | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 489 | ▶ | if ! $uSize->equal(*$self->{UnCompSize}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||
| 282 | 1039 | my $reachedEnd = STATUS_ERROR ; | |||||||||||||||||||||||||||||||||||||||||
| 283 | # check for central directory or end of central directory | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 1039 | while (1) | |||||||||||||||||||||||||||||||||||||||||
| 285 | { | ||||||||||||||||||||||||||||||||||||||||||
| 286 | 2113 | my $magic ; | |||||||||||||||||||||||||||||||||||||||||
| 287 | 2113 | my $got = $self->smartRead(\$magic, 4); | |||||||||||||||||||||||||||||||||||||||||
| 288 | |||||||||||||||||||||||||||||||||||||||||||
| 289 | return $self->saveErrorString(STATUS_ERROR, "Truncated file") | ||||||||||||||||||||||||||||||||||||||||||
| 290 | 2113 | ▶ | if $got != 4 && *$self->{Strict}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$got != 4 and *$self->{"Strict"}
MC/DC0%0/2
$got != 4 and *$self->{"Strict"}
$got != 4
*$self->{"Strict"}
Truth table33%1/3
A and B
A= $got != 4B= *$self->{"Strict"}
| |||||||||||||||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||||||||||||
| 292 | 2113 | ▶ | if ($got == 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | return STATUS_EOF ; | |||||||||||||||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||||||||||||||||
| 295 | elsif ($got < 0) { | ||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | return STATUS_ERROR ; | |||||||||||||||||||||||||||||||||||||||||
| 297 | } | ||||||||||||||||||||||||||||||||||||||||||
| 298 | elsif ($got < 4) { | ||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | $self->pushBack($magic) ; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | 2113 | my $sig = unpack("V", $magic) ; | |||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | 2113 | my $hdr; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 2113 | ▶ | if ($hdr = $headerLookup{$sig}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 307 | { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 1725 | ▶ | if (&$hdr($self, $magic) != STATUS_OK ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if (*$self->{Strict}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | return STATUS_ERROR ; | |||||||||||||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||||||||||||
| 312 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | $self->clearError(); | |||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 315 | } | ||||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | |||||||||||||||||||||||||||||||||||||||||||
| 318 | 1725 | ▶ | if ($sig == ZIP_END_CENTRAL_HDR_SIG) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 319 | { | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 651 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | elsif ($sig == ZIP_LOCAL_HDR_SIG) | ||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 388 | $self->pushBack($magic) ; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 388 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||||||||||||
| 329 | else | ||||||||||||||||||||||||||||||||||||||||||
| 330 | { | ||||||||||||||||||||||||||||||||||||||||||
| 331 | # put the data back | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $self->pushBack($magic) ; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 334 | } | ||||||||||||||||||||||||||||||||||||||||||
| 335 | } | ||||||||||||||||||||||||||||||||||||||||||
| 336 | |||||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | return $reachedEnd ; | |||||||||||||||||||||||||||||||||||||||||
| 338 | } | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | sub skipCentralDirectory | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 1006 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipCentralDirectory: called CC=8 SCAR=20.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 342 | 1006 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 343 | 1006 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 344 | |||||||||||||||||||||||||||||||||||||||||||
| 345 | 1006 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 346 | 1006 | ▶ | $self->smartReadExact(\$buffer, 46 - 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 347 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 46 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | 1006 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 1006 | *$self->{HeaderPending} = $keep ; | |||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | #my $versionMadeBy = unpack ("v", substr($buffer, 4-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 354 | #my $extractVersion = unpack ("v", substr($buffer, 6-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 355 | #my $gpFlag = unpack ("v", substr($buffer, 8-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 356 | #my $compressedMethod = unpack ("v", substr($buffer, 10-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 357 | #my $lastModTime = unpack ("V", substr($buffer, 12-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 358 | #my $crc32 = unpack ("V", substr($buffer, 16-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 359 | 1006 | my $compressedLength = unpack ("V", substr($buffer, 20-4, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 360 | 1006 | my $uncompressedLength = unpack ("V", substr($buffer, 24-4, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 361 | 1006 | my $filename_length = unpack ("v", substr($buffer, 28-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 362 | 1006 | my $extra_length = unpack ("v", substr($buffer, 30-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 363 | 1006 | my $comment_length = unpack ("v", substr($buffer, 32-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 364 | #my $disk_start = unpack ("v", substr($buffer, 34-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 365 | #my $int_file_attrib = unpack ("v", substr($buffer, 36-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 366 | #my $ext_file_attrib = unpack ("V", substr($buffer, 38-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | #my $lcl_hdr_offset = unpack ("V", substr($buffer, 42-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | 1006 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 371 | my $extraField; | ||||||||||||||||||||||||||||||||||||||||||
| 372 | 1006 | my $comment ; | |||||||||||||||||||||||||||||||||||||||||
| 373 | 1006 | ▶ | if ($filename_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | { | ||||||||||||||||||||||||||||||||||||||||||
| 375 | 240 | ▶ | $self->smartReadExact(\$filename, $filename_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | or return $self->TruncatedTrailer("filename"); | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 240 | $keep .= $filename ; | |||||||||||||||||||||||||||||||||||||||||
| 378 | } | ||||||||||||||||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||||||||||||||||
| 380 | 1006 | ▶ | if ($extra_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 381 | { | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 166 | ▶ | $self->smartReadExact(\$extraField, $extra_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | or return $self->TruncatedTrailer("extra"); | ||||||||||||||||||||||||||||||||||||||||||
| 384 | 166 | $keep .= $extraField ; | |||||||||||||||||||||||||||||||||||||||||
| 385 | } | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | 1006 | ▶ | if ($comment_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 388 | { | ||||||||||||||||||||||||||||||||||||||||||
| 389 | 1 | ▶ | $self->smartReadExact(\$comment, $comment_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 390 | or return $self->TruncatedTrailer("comment"); | ||||||||||||||||||||||||||||||||||||||||||
| 391 | 1 | $keep .= $comment ; | |||||||||||||||||||||||||||||||||||||||||
| 392 | } | ||||||||||||||||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||||||||||||||||
| 394 | 1006 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 395 | } | ||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||
| 397 | sub skipArchiveExtra | ||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipArchiveExtra: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | $self->smartReadExact(\$buffer, 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 404 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 405 | 4 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | my $size = unpack ("V", $buffer); | |||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | $self->smartReadExact(\$buffer, $size) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 412 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 413 | $size . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $keep .= $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | *$self->{HeaderPending} = $keep ; | |||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 419 | } | ||||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | sub skipCentralDirectory64Rec | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 34 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipCentralDirectory64Rec: called CC=3 SCAR=11.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 424 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 425 | 34 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||||||||||||||||
| 427 | 34 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 428 | 34 | ▶ | $self->smartReadExact(\$buffer, 8) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 8 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 34 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 34 | my ($sizeLo, $sizeHi) = unpack ("V V", $buffer); | |||||||||||||||||||||||||||||||||||||||||
| 435 | 34 | my $size = $sizeHi * U64::MAX32 + $sizeLo; | |||||||||||||||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||||||||||||||||
| 437 | 34 | ▶ | $self->fastForward($size) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 438 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 439 | $size . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||
| 441 | #$keep .= $buffer ; | ||||||||||||||||||||||||||||||||||||||||||
| 442 | #*$self->{HeaderPending} = $keep ; | ||||||||||||||||||||||||||||||||||||||||||
| 443 | |||||||||||||||||||||||||||||||||||||||||||
| 444 | #my $versionMadeBy = unpack ("v", substr($buffer, 0, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 445 | #my $extractVersion = unpack ("v", substr($buffer, 2, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 446 | #my $diskNumber = unpack ("V", substr($buffer, 4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 447 | #my $cntrlDirDiskNo = unpack ("V", substr($buffer, 8, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 448 | #my $entriesInThisCD = unpack ("V V", substr($buffer, 12, 8)); | ||||||||||||||||||||||||||||||||||||||||||
| 449 | #my $entriesInCD = unpack ("V V", substr($buffer, 20, 8)); | ||||||||||||||||||||||||||||||||||||||||||
| 450 | #my $sizeOfCD = unpack ("V V", substr($buffer, 28, 8)); | ||||||||||||||||||||||||||||||||||||||||||
| 451 | #my $offsetToCD = unpack ("V V", substr($buffer, 36, 8)); | ||||||||||||||||||||||||||||||||||||||||||
| 452 | |||||||||||||||||||||||||||||||||||||||||||
| 453 | 34 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 454 | } | ||||||||||||||||||||||||||||||||||||||||||
| 455 | |||||||||||||||||||||||||||||||||||||||||||
| 456 | sub skipCentralDirectory64Loc | ||||||||||||||||||||||||||||||||||||||||||
| 457 | 34 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipCentralDirectory64Loc: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 458 | 34 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 459 | 34 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 34 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 462 | 34 | ▶ | $self->smartReadExact(\$buffer, 20 - 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 20 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 465 | |||||||||||||||||||||||||||||||||||||||||||
| 466 | 34 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 467 | 34 | *$self->{HeaderPending} = $keep ; | |||||||||||||||||||||||||||||||||||||||||
| 468 | |||||||||||||||||||||||||||||||||||||||||||
| 469 | #my $startCdDisk = unpack ("V", substr($buffer, 4-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 470 | #my $offsetToCD = unpack ("V V", substr($buffer, 8-4, 8)); | ||||||||||||||||||||||||||||||||||||||||||
| 471 | #my $diskCount = unpack ("V", substr($buffer, 16-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 34 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||
| 476 | sub skipEndCentralDirectory | ||||||||||||||||||||||||||||||||||||||||||
| 477 | 651 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skipEndCentralDirectory: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 478 | 651 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 479 | 651 | my $magic = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | |||||||||||||||||||||||||||||||||||||||||||
| 482 | 651 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 651 | ▶ | $self->smartReadExact(\$buffer, 22 - 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 484 | or return $self->TrailerError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 485 | 22 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 486 | |||||||||||||||||||||||||||||||||||||||||||
| 487 | 651 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 488 | 651 | *$self->{HeaderPending} = $keep ; | |||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | #my $diskNumber = unpack ("v", substr($buffer, 4-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 491 | #my $cntrlDirDiskNo = unpack ("v", substr($buffer, 6-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 492 | #my $entriesInThisCD = unpack ("v", substr($buffer, 8-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 493 | #my $entriesInCD = unpack ("v", substr($buffer, 10-4, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 494 | #my $sizeOfCD = unpack ("V", substr($buffer, 12-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 495 | #my $offsetToCD = unpack ("V", substr($buffer, 16-4, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 496 | 651 | my $comment_length = unpack ("v", substr($buffer, 20-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 497 | |||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | 651 | my $comment ; | |||||||||||||||||||||||||||||||||||||||||
| 500 | 651 | ▶ | if ($comment_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 501 | { | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | $self->smartReadExact(\$comment, $comment_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | or return $self->TruncatedTrailer("comment"); | ||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $keep .= $comment ; | |||||||||||||||||||||||||||||||||||||||||
| 505 | } | ||||||||||||||||||||||||||||||||||||||||||
| 506 | |||||||||||||||||||||||||||||||||||||||||||
| 507 | 651 | return STATUS_OK ; | |||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||
| 509 | |||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||
| 511 | sub _isZipMagic | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 1379 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_isZipMagic: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||||||||||||
| 513 | 1379 | my $buffer = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 514 | 1379 | ▶ | return 0 if length $buffer < 4 ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 515 | 1379 | my $sig = unpack("V", $buffer) ; | |||||||||||||||||||||||||||||||||||||||||
| 516 | 1379 | return $sig == ZIP_LOCAL_HDR_SIG ; | |||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | |||||||||||||||||||||||||||||||||||||||||||
| 520 | sub _readFullZipHeader($) | ||||||||||||||||||||||||||||||||||||||||||
| 521 | 37 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readFullZipHeader: called CC=4 SCAR=14.2
| |||||||||||||||||||||||||||||||||||||||||||
| 522 | 37 | my ($self) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 523 | 37 | my $magic = '' ; | |||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | 37 | $self->smartReadExact(\$magic, 4); | |||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 37 | *$self->{HeaderPending} = $magic ; | |||||||||||||||||||||||||||||||||||||||||
| 528 | |||||||||||||||||||||||||||||||||||||||||||
| 529 | 37 | ▶ | return $self->HeaderError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 530 | 30 . " bytes") | ||||||||||||||||||||||||||||||||||||||||||
| 531 | if length $magic != 4 ; | ||||||||||||||||||||||||||||||||||||||||||
| 532 | |||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 37 | ▶ | return $self->HeaderError("Bad Magic") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 535 | if ! _isZipMagic($magic) ; | ||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 37 | my $status = $self->_readZipHeader($magic); | |||||||||||||||||||||||||||||||||||||||||
| 538 | 37 | ▶ | delete *$self->{Transparent} if ! defined $status ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | 37 | return $status ; | |||||||||||||||||||||||||||||||||||||||||
| 540 | } | ||||||||||||||||||||||||||||||||||||||||||
| 541 | |||||||||||||||||||||||||||||||||||||||||||
| 542 | sub _readZipHeader($) | ||||||||||||||||||||||||||||||||||||||||||
| 543 | 1055 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_readZipHeader: called CC=38 SCAR=43.0
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | 1055 | my ($self, $magic) = @_ ; | |||||||||||||||||||||||||||||||||||||||||
| 545 | 1055 | my ($HeaderCRC) ; | |||||||||||||||||||||||||||||||||||||||||
| 546 | 1055 | my ($buffer) = '' ; | |||||||||||||||||||||||||||||||||||||||||
| 547 | |||||||||||||||||||||||||||||||||||||||||||
| 548 | 1055 | ▶ | $self->smartReadExact(\$buffer, 30 - 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 549 | or return $self->HeaderError("Minimum header size is " . | ||||||||||||||||||||||||||||||||||||||||||
| 550 | 30 . " bytes") ; | ||||||||||||||||||||||||||||||||||||||||||
| 551 | |||||||||||||||||||||||||||||||||||||||||||
| 552 | 1055 | my $keep = $magic . $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 553 | 1055 | *$self->{HeaderPending} = $keep ; | |||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 1055 | my $extractVersion = unpack ("v", substr($buffer, 4-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 556 | 1055 | my $gpFlag = unpack ("v", substr($buffer, 6-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 557 | 1055 | my $compressedMethod = unpack ("v", substr($buffer, 8-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 558 | 1055 | my $lastModTime = unpack ("V", substr($buffer, 10-4, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 559 | 1055 | my $crc32 = unpack ("V", substr($buffer, 14-4, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 560 | 1055 | my $compressedLength = U64::newUnpack_V32 substr($buffer, 18-4, 4); | |||||||||||||||||||||||||||||||||||||||||
| 561 | 1055 | my $uncompressedLength = U64::newUnpack_V32 substr($buffer, 22-4, 4); | |||||||||||||||||||||||||||||||||||||||||
| 562 | 1055 | my $filename_length = unpack ("v", substr($buffer, 26-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 563 | 1055 | my $extra_length = unpack ("v", substr($buffer, 28-4, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 564 | |||||||||||||||||||||||||||||||||||||||||||
| 565 | 1055 | my $filename; | |||||||||||||||||||||||||||||||||||||||||
| 566 | my $extraField; | ||||||||||||||||||||||||||||||||||||||||||
| 567 | 1055 | my @EXTRA = (); | |||||||||||||||||||||||||||||||||||||||||
| 568 | |||||||||||||||||||||||||||||||||||||||||||
| 569 | # Some programs (some versions of LibreOffice) mark entries as streamed, but still fill out | ||||||||||||||||||||||||||||||||||||||||||
| 570 | # compressedLength/uncompressedLength & crc32 in the local file header. | ||||||||||||||||||||||||||||||||||||||||||
| 571 | # The expected data descriptor is not populated. | ||||||||||||||||||||||||||||||||||||||||||
| 572 | # So only assume streaming if the Streaming bit is set AND the compressed length is zero | ||||||||||||||||||||||||||||||||||||||||||
| 573 | 1055 | ▶ | my $streamingMode = (($gpFlag & ZIP_GP_FLAG_STREAMING_MASK) && $crc32 == 0) ? 1 : 0 ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$gpFlag & 8 and $crc32 == 0
MC/DC100%2/2
$gpFlag & 8 and $crc32 == 0
$gpFlag & 8
$crc32 == 0
Truth table100%3/3
A and B
A= $gpFlag & 8B= $crc32 == 0
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | |||||||||||||||||||||||||||||||||||||||||||
| 575 | 1055 | ▶ | my $efs_flag = ($gpFlag & ZIP_GP_FLAG_LANGUAGE_ENCODING) ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 576 | |||||||||||||||||||||||||||||||||||||||||||
| 577 | 1055 | ▶ | return $self->HeaderError("Encrypted content not supported") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 578 | if $gpFlag & (ZIP_GP_FLAG_ENCRYPTED_MASK|ZIP_GP_FLAG_STRONG_ENCRYPTED_MASK); | ||||||||||||||||||||||||||||||||||||||||||
| 579 | |||||||||||||||||||||||||||||||||||||||||||
| 580 | 1053 | ▶ | return $self->HeaderError("Patch content not supported") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | if $gpFlag & ZIP_GP_FLAG_PATCHED_MASK; | ||||||||||||||||||||||||||||||||||||||||||
| 582 | |||||||||||||||||||||||||||||||||||||||||||
| 583 | 1053 | *$self->{ZipData}{Streaming} = $streamingMode; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | |||||||||||||||||||||||||||||||||||||||||||
| 586 | 1053 | ▶ | if ($filename_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 587 | { | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 278 | ▶ | $self->smartReadExact(\$filename, $filename_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 589 | or return $self->TruncatedHeader("Filename"); | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 278 | ▶ | if (*$self->{UnzipData}{efs} && $efs_flag && $] >= 5.008004) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%4/6
*$self->{"UnzipData"}{"efs"} and $efs_flag and $] >= "5.008004"
*$self->{"UnzipData"}{"efs"} and $efs_flag
MC/DC33%1/3
*$self->{"UnzipData"}{"efs"} and $efs_flag and $] >= "5.008004"
*$self->{"UnzipData"}{"efs"}
$efs_flag
$] >= "5.008004"
Truth table50%2/4
A and B and C
A= *$self->{"UnzipData"}{"efs"}B= $efs_flagC= $] >= "5.008004"
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | { | ||||||||||||||||||||||||||||||||||||||||||
| 593 | 5 | require Encode; | |||||||||||||||||||||||||||||||||||||||||
| 594 | 5 | ▶ | eval { $filename = Encode::decode_utf8($filename, 1) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 595 | or Carp::croak "Zip Filename not UTF-8" ; | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | 277 | $keep .= $filename ; | |||||||||||||||||||||||||||||||||||||||||
| 599 | } | ||||||||||||||||||||||||||||||||||||||||||
| 600 | |||||||||||||||||||||||||||||||||||||||||||
| 601 | 1052 | my $zip64 = 0 ; | |||||||||||||||||||||||||||||||||||||||||
| 602 | |||||||||||||||||||||||||||||||||||||||||||
| 603 | 1052 | ▶ | if ($extra_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 604 | { | ||||||||||||||||||||||||||||||||||||||||||
| 605 | 197 | ▶ | $self->smartReadExact(\$extraField, $extra_length) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 606 | or return $self->TruncatedHeader("Extra Field"); | ||||||||||||||||||||||||||||||||||||||||||
| 607 | |||||||||||||||||||||||||||||||||||||||||||
| 608 | 197 | my $bad = IO::Compress::Zlib::Extra::parseRawExtra($extraField, | |||||||||||||||||||||||||||||||||||||||||
| 609 | \@EXTRA, 1, 0); | ||||||||||||||||||||||||||||||||||||||||||
| 610 | 197 | ▶ | return $self->HeaderError($bad) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 611 | if defined $bad; | ||||||||||||||||||||||||||||||||||||||||||
| 612 | |||||||||||||||||||||||||||||||||||||||||||
| 613 | 197 | $keep .= $extraField ; | |||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | 197 | my %Extra ; | |||||||||||||||||||||||||||||||||||||||||
| 616 | 197 | for (@EXTRA) | |||||||||||||||||||||||||||||||||||||||||
| 617 | { | ||||||||||||||||||||||||||||||||||||||||||
| 618 | 400 | $Extra{$_->[0]} = \$_->[1]; | |||||||||||||||||||||||||||||||||||||||||
| 619 | } | ||||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | 197 | ▶ | if (defined $Extra{ZIP_EXTRA_ID_ZIP64()}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 622 | { | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 47 | $zip64 = 1 ; | |||||||||||||||||||||||||||||||||||||||||
| 624 | |||||||||||||||||||||||||||||||||||||||||||
| 625 | 47 | my $buff = ${ $Extra{ZIP_EXTRA_ID_ZIP64()} }; | |||||||||||||||||||||||||||||||||||||||||
| 626 | |||||||||||||||||||||||||||||||||||||||||||
| 627 | # This code assumes that all the fields in the Zip64 | ||||||||||||||||||||||||||||||||||||||||||
| 628 | # extra field aren't necessarily present. The spec says that | ||||||||||||||||||||||||||||||||||||||||||
| 629 | # they only exist if the equivalent local headers are -1. | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | 47 | ▶ | if (! $streamingMode) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 632 | 16 | my $offset = 0 ; | |||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||
| 634 | 16 | ▶ | if (U64::full32 $uncompressedLength->get32bit() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 635 | 16 | $uncompressedLength | |||||||||||||||||||||||||||||||||||||||||
| 636 | = U64::newUnpack_V64 substr($buff, 0, 8); | ||||||||||||||||||||||||||||||||||||||||||
| 637 | |||||||||||||||||||||||||||||||||||||||||||
| 638 | 16 | $offset += 8 ; | |||||||||||||||||||||||||||||||||||||||||
| 639 | } | ||||||||||||||||||||||||||||||||||||||||||
| 640 | |||||||||||||||||||||||||||||||||||||||||||
| 641 | 16 | ▶ | if (U64::full32 $compressedLength->get32bit() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 642 | |||||||||||||||||||||||||||||||||||||||||||
| 643 | 16 | $compressedLength | |||||||||||||||||||||||||||||||||||||||||
| 644 | = U64::newUnpack_V64 substr($buff, $offset, 8); | ||||||||||||||||||||||||||||||||||||||||||
| 645 | |||||||||||||||||||||||||||||||||||||||||||
| 646 | 16 | $offset += 8 ; | |||||||||||||||||||||||||||||||||||||||||
| 647 | } | ||||||||||||||||||||||||||||||||||||||||||
| 648 | } | ||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||
| 650 | } | ||||||||||||||||||||||||||||||||||||||||||
| 651 | |||||||||||||||||||||||||||||||||||||||||||
| 652 | 1052 | *$self->{ZipData}{Zip64} = $zip64; | |||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||
| 654 | 1052 | ▶ | if (! $streamingMode) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 655 | 110 | *$self->{ZipData}{Streaming} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 656 | 110 | *$self->{ZipData}{Crc32} = $crc32; | |||||||||||||||||||||||||||||||||||||||||
| 657 | 110 | *$self->{ZipData}{CompressedLen} = $compressedLength; | |||||||||||||||||||||||||||||||||||||||||
| 658 | 110 | *$self->{ZipData}{UnCompressedLen} = $uncompressedLength; | |||||||||||||||||||||||||||||||||||||||||
| 659 | *$self->{CompressedInputLengthRemaining} = | ||||||||||||||||||||||||||||||||||||||||||
| 660 | 110 | *$self->{CompressedInputLength} = $compressedLength->get64bit(); | |||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | |||||||||||||||||||||||||||||||||||||||||||
| 663 | 1052 | *$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32(undef); | |||||||||||||||||||||||||||||||||||||||||
| 664 | 1052 | *$self->{ZipData}{Method} = $compressedMethod; | |||||||||||||||||||||||||||||||||||||||||
| 665 | 1052 | ▶ | if ($compressedMethod == ZIP_CM_DEFLATE) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 6 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 666 | { | ||||||||||||||||||||||||||||||||||||||||||
| 667 | 943 | *$self->{Type} = 'zip-deflate'; | |||||||||||||||||||||||||||||||||||||||||
| 668 | 943 | my $obj = IO::Uncompress::Adapter::Inflate::mkUncompObject(1,0,0); | |||||||||||||||||||||||||||||||||||||||||
| 669 | |||||||||||||||||||||||||||||||||||||||||||
| 670 | 943 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 671 | } | ||||||||||||||||||||||||||||||||||||||||||
| 672 | elsif ($compressedMethod == ZIP_CM_BZIP2) | ||||||||||||||||||||||||||||||||||||||||||
| 673 | { | ||||||||||||||||||||||||||||||||||||||||||
| 674 | 32 | ▶ | return $self->HeaderError("Unsupported Compression format $compressedMethod") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | if ! defined $IO::Uncompress::Adapter::Bunzip2::VERSION ; | ||||||||||||||||||||||||||||||||||||||||||
| 676 | |||||||||||||||||||||||||||||||||||||||||||
| 677 | 32 | *$self->{Type} = 'zip-bzip2'; | |||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||
| 679 | 32 | my $obj = IO::Uncompress::Adapter::Bunzip2::mkUncompObject(); | |||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 32 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 682 | } | ||||||||||||||||||||||||||||||||||||||||||
| 683 | elsif ($compressedMethod == ZIP_CM_XZ) | ||||||||||||||||||||||||||||||||||||||||||
| 684 | { | ||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | ▶ | return $self->HeaderError("Unsupported Compression format $compressedMethod") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 686 | if ! defined $IO::Uncompress::Adapter::UnXz::VERSION ; | ||||||||||||||||||||||||||||||||||||||||||
| 687 | |||||||||||||||||||||||||||||||||||||||||||
| 688 | 0 | *$self->{Type} = 'zip-xz'; | |||||||||||||||||||||||||||||||||||||||||
| 689 | |||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | my $obj = IO::Uncompress::Adapter::UnXz::mkUncompObject(); | |||||||||||||||||||||||||||||||||||||||||
| 691 | |||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 693 | } | ||||||||||||||||||||||||||||||||||||||||||
| 694 | elsif ($compressedMethod == ZIP_CM_ZSTD) | ||||||||||||||||||||||||||||||||||||||||||
| 695 | { | ||||||||||||||||||||||||||||||||||||||||||
| 696 | 0 | ▶ | return $self->HeaderError("Unsupported Compression format $compressedMethod") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 697 | if ! defined $IO::Uncompress::Adapter::UnZstd::VERSION ; | ||||||||||||||||||||||||||||||||||||||||||
| 698 | |||||||||||||||||||||||||||||||||||||||||||
| 699 | 0 | *$self->{Type} = 'zip-zstd'; | |||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | my $obj = IO::Uncompress::Adapter::UnZstd::mkUncompObject(); | |||||||||||||||||||||||||||||||||||||||||
| 702 | |||||||||||||||||||||||||||||||||||||||||||
| 703 | 0 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 704 | } | ||||||||||||||||||||||||||||||||||||||||||
| 705 | elsif ($compressedMethod == ZIP_CM_LZMA) | ||||||||||||||||||||||||||||||||||||||||||
| 706 | { | ||||||||||||||||||||||||||||||||||||||||||
| 707 | 0 | ▶ | return $self->HeaderError("Unsupported Compression format $compressedMethod") | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 708 | if ! defined $IO::Uncompress::Adapter::UnLzma::VERSION ; | ||||||||||||||||||||||||||||||||||||||||||
| 709 | |||||||||||||||||||||||||||||||||||||||||||
| 710 | 0 | *$self->{Type} = 'zip-lzma'; | |||||||||||||||||||||||||||||||||||||||||
| 711 | 0 | my $LzmaHeader; | |||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | $self->smartReadExact(\$LzmaHeader, 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 713 | or return $self->saveErrorString(undef, "Truncated file"); | ||||||||||||||||||||||||||||||||||||||||||
| 714 | 0 | my ($verHi, $verLo) = unpack ("CC", substr($LzmaHeader, 0, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | my $LzmaPropertiesSize = unpack ("v", substr($LzmaHeader, 2, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 716 | |||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||
| 718 | 0 | my $LzmaPropertyData; | |||||||||||||||||||||||||||||||||||||||||
| 719 | 0 | ▶ | $self->smartReadExact(\$LzmaPropertyData, $LzmaPropertiesSize) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 720 | or return $self->saveErrorString(undef, "Truncated file"); | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | if (! $streamingMode) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | *$self->{ZipData}{CompressedLen}->subtract(4 + $LzmaPropertiesSize) ; | |||||||||||||||||||||||||||||||||||||||||
| 724 | *$self->{CompressedInputLengthRemaining} = | ||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | *$self->{CompressedInputLength} = *$self->{ZipData}{CompressedLen}->get64bit(); | |||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||
| 728 | 0 | my $obj = | |||||||||||||||||||||||||||||||||||||||||
| 729 | IO::Uncompress::Adapter::UnLzma::mkUncompZipObject($LzmaPropertyData); | ||||||||||||||||||||||||||||||||||||||||||
| 730 | |||||||||||||||||||||||||||||||||||||||||||
| 731 | 0 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 732 | } | ||||||||||||||||||||||||||||||||||||||||||
| 733 | elsif ($compressedMethod == ZIP_CM_STORE) | ||||||||||||||||||||||||||||||||||||||||||
| 734 | { | ||||||||||||||||||||||||||||||||||||||||||
| 735 | 77 | *$self->{Type} = 'zip-stored'; | |||||||||||||||||||||||||||||||||||||||||
| 736 | |||||||||||||||||||||||||||||||||||||||||||
| 737 | 77 | my $obj = | |||||||||||||||||||||||||||||||||||||||||
| 738 | IO::Uncompress::Adapter::Identity::mkUncompObject($streamingMode, | ||||||||||||||||||||||||||||||||||||||||||
| 739 | $zip64); | ||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||
| 741 | 77 | *$self->{Uncomp} = $obj; | |||||||||||||||||||||||||||||||||||||||||
| 742 | } | ||||||||||||||||||||||||||||||||||||||||||
| 743 | else | ||||||||||||||||||||||||||||||||||||||||||
| 744 | { | ||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | return $self->HeaderError("Unsupported Compression format $compressedMethod"); | |||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 747 | |||||||||||||||||||||||||||||||||||||||||||
| 748 | return { | ||||||||||||||||||||||||||||||||||||||||||
| 749 | 'Type' => 'zip', | ||||||||||||||||||||||||||||||||||||||||||
| 750 | 'FingerprintLength' => 4, | ||||||||||||||||||||||||||||||||||||||||||
| 751 | #'HeaderLength' => $compressedMethod == 8 ? length $keep : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 752 | 'HeaderLength' => length $keep, | ||||||||||||||||||||||||||||||||||||||||||
| 753 | 'Zip64' => $zip64, | ||||||||||||||||||||||||||||||||||||||||||
| 754 | 'TrailerLength' => ! $streamingMode ? 0 : $zip64 ? 24 : 16, | ||||||||||||||||||||||||||||||||||||||||||
| 755 | 'Header' => $keep, | ||||||||||||||||||||||||||||||||||||||||||
| 756 | 'CompressedLength' => $compressedLength , | ||||||||||||||||||||||||||||||||||||||||||
| 757 | 'UncompressedLength' => $uncompressedLength , | ||||||||||||||||||||||||||||||||||||||||||
| 758 | 'CRC32' => $crc32 , | ||||||||||||||||||||||||||||||||||||||||||
| 759 | 'Name' => $filename, | ||||||||||||||||||||||||||||||||||||||||||
| 760 | 'efs' => $efs_flag, # language encoding flag | ||||||||||||||||||||||||||||||||||||||||||
| 761 | 'Time' => _dosToUnixTime($lastModTime), | ||||||||||||||||||||||||||||||||||||||||||
| 762 | 'Stream' => $streamingMode, | ||||||||||||||||||||||||||||||||||||||||||
| 763 | |||||||||||||||||||||||||||||||||||||||||||
| 764 | 'MethodID' => $compressedMethod, | ||||||||||||||||||||||||||||||||||||||||||
| 765 | 1052 | ▶ | 'MethodName' => $MethodNames{$compressedMethod} || 'Unknown', | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition50%1/2
$MethodNames{$compressedMethod} || 'Unknown'
MC/DC0%0/1
$MethodNames{$compressedMethod} || 'Unknown'
$MethodNames{$compressedMethod}
Truth table50%1/2
A
A= $MethodNames{$compressedMethod}
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | |||||||||||||||||||||||||||||||||||||||||||
| 767 | # 'TextFlag' => $flag & GZIP_FLG_FTEXT ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 768 | # 'HeaderCRCFlag' => $flag & GZIP_FLG_FHCRC ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 769 | # 'NameFlag' => $flag & GZIP_FLG_FNAME ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 770 | # 'CommentFlag' => $flag & GZIP_FLG_FCOMMENT ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 771 | # 'ExtraFlag' => $flag & GZIP_FLG_FEXTRA ? 1 : 0, | ||||||||||||||||||||||||||||||||||||||||||
| 772 | # 'Comment' => $comment, | ||||||||||||||||||||||||||||||||||||||||||
| 773 | # 'OsID' => $os, | ||||||||||||||||||||||||||||||||||||||||||
| 774 | # 'OsName' => defined $GZIP_OS_Names{$os} | ||||||||||||||||||||||||||||||||||||||||||
| 775 | # ? $GZIP_OS_Names{$os} : "Unknown", | ||||||||||||||||||||||||||||||||||||||||||
| 776 | # 'HeaderCRC' => $HeaderCRC, | ||||||||||||||||||||||||||||||||||||||||||
| 777 | # 'Flags' => $flag, | ||||||||||||||||||||||||||||||||||||||||||
| 778 | # 'ExtraFlags' => $xfl, | ||||||||||||||||||||||||||||||||||||||||||
| 779 | 'ExtraFieldRaw' => $extraField, | ||||||||||||||||||||||||||||||||||||||||||
| 780 | 'ExtraField' => [ @EXTRA ], | ||||||||||||||||||||||||||||||||||||||||||
| 781 | |||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | } | ||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||
| 786 | sub filterUncompressed | ||||||||||||||||||||||||||||||||||||||||||
| 787 | 1222 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
filterUncompressed: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 788 | 1222 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 789 | |||||||||||||||||||||||||||||||||||||||||||
| 790 | 1222 | ▶ | if (*$self->{ZipData}{Method} == ZIP_CM_DEFLATE) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 791 | 1125 | *$self->{ZipData}{CRC32} = *$self->{Uncomp}->crc32() ; | |||||||||||||||||||||||||||||||||||||||||
| 792 | } | ||||||||||||||||||||||||||||||||||||||||||
| 793 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 794 | 97 | *$self->{ZipData}{CRC32} = Compress::Raw::Zlib::crc32(${$_[0]}, *$self->{ZipData}{CRC32}, $_[1]); | |||||||||||||||||||||||||||||||||||||||||
| 795 | } | ||||||||||||||||||||||||||||||||||||||||||
| 796 | } | ||||||||||||||||||||||||||||||||||||||||||
| 797 | |||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | # from Archive::Zip & info-zip | ||||||||||||||||||||||||||||||||||||||||||
| 800 | sub _dosToUnixTime | ||||||||||||||||||||||||||||||||||||||||||
| 801 | 1052 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_dosToUnixTime: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 802 | # Returns zero when $dt is already zero or it doesn't expand to a value that Time::Local::timelocal() | ||||||||||||||||||||||||||||||||||||||||||
| 803 | # can handle. | ||||||||||||||||||||||||||||||||||||||||||
| 804 | |||||||||||||||||||||||||||||||||||||||||||
| 805 | 1052 | my $dt = shift; | |||||||||||||||||||||||||||||||||||||||||
| 806 | # warn "_dosToUnixTime dt=[$dt]\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 807 | |||||||||||||||||||||||||||||||||||||||||||
| 808 | # some zip files don't populate the datetime field at all | ||||||||||||||||||||||||||||||||||||||||||
| 809 | 1052 | ▶ | return 0 if ! $dt; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | 1051 | my $year = ( ( $dt >> 25 ) & 0x7f ) + 80; | |||||||||||||||||||||||||||||||||||||||||
| 812 | 1051 | my $mon = ( ( $dt >> 21 ) & 0x0f ) - 1; | |||||||||||||||||||||||||||||||||||||||||
| 813 | 1051 | my $mday = ( ( $dt >> 16 ) & 0x1f ); | |||||||||||||||||||||||||||||||||||||||||
| 814 | |||||||||||||||||||||||||||||||||||||||||||
| 815 | 1051 | my $hour = ( ( $dt >> 11 ) & 0x1f ); | |||||||||||||||||||||||||||||||||||||||||
| 816 | 1051 | my $min = ( ( $dt >> 5 ) & 0x3f ); | |||||||||||||||||||||||||||||||||||||||||
| 817 | 1051 | my $sec = ( ( $dt << 1 ) & 0x3e ); | |||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 83 | ▶ | use Time::Local ; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | |||||||||||||||||||||||||||||||||||||||||||
| 821 | 1051 | my $time_t ; | |||||||||||||||||||||||||||||||||||||||||
| 822 | # wrap in an eval to catch out of range errors | ||||||||||||||||||||||||||||||||||||||||||
| 823 | 1051 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 824 | 1051 | $time_t = Time::Local::timelocal( $sec, $min, $hour, $mday, $mon, $year); | |||||||||||||||||||||||||||||||||||||||||
| 825 | } ; | ||||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | 1051 | ▶ | return 0 if ! defined $time_t; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 828 | 1050 | return $time_t; | |||||||||||||||||||||||||||||||||||||||||
| 829 | } | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | #sub scanCentralDirectory | ||||||||||||||||||||||||||||||||||||||||||
| 832 | #{ | ||||||||||||||||||||||||||||||||||||||||||
| 833 | # # Use cases | ||||||||||||||||||||||||||||||||||||||||||
| 834 | # # 1 32-bit CD | ||||||||||||||||||||||||||||||||||||||||||
| 835 | # # 2 64-bit CD | ||||||||||||||||||||||||||||||||||||||||||
| 836 | # | ||||||||||||||||||||||||||||||||||||||||||
| 837 | # my $self = shift ; | ||||||||||||||||||||||||||||||||||||||||||
| 838 | # | ||||||||||||||||||||||||||||||||||||||||||
| 839 | # my @CD = (); | ||||||||||||||||||||||||||||||||||||||||||
| 840 | # my $offset = $self->findCentralDirectoryOffset(); | ||||||||||||||||||||||||||||||||||||||||||
| 841 | # | ||||||||||||||||||||||||||||||||||||||||||
| 842 | # return 0 | ||||||||||||||||||||||||||||||||||||||||||
| 843 | # if ! defined $offset; | ||||||||||||||||||||||||||||||||||||||||||
| 844 | # | ||||||||||||||||||||||||||||||||||||||||||
| 845 | # $self->smarkSeek($offset, 0, SEEK_SET) ; | ||||||||||||||||||||||||||||||||||||||||||
| 846 | # | ||||||||||||||||||||||||||||||||||||||||||
| 847 | # # Now walk the Central Directory Records | ||||||||||||||||||||||||||||||||||||||||||
| 848 | # my $buffer ; | ||||||||||||||||||||||||||||||||||||||||||
| 849 | # while ($self->smartReadExact(\$buffer, 46) && | ||||||||||||||||||||||||||||||||||||||||||
| 850 | # unpack("V", $buffer) == ZIP_CENTRAL_HDR_SIG) { | ||||||||||||||||||||||||||||||||||||||||||
| 851 | # | ||||||||||||||||||||||||||||||||||||||||||
| 852 | # my $compressedLength = unpack ("V", substr($buffer, 20, 4)); | ||||||||||||||||||||||||||||||||||||||||||
| 853 | # my $filename_length = unpack ("v", substr($buffer, 28, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 854 | # my $extra_length = unpack ("v", substr($buffer, 30, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 855 | # my $comment_length = unpack ("v", substr($buffer, 32, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 856 | # | ||||||||||||||||||||||||||||||||||||||||||
| 857 | # $self->smarkSeek($filename_length + $extra_length + $comment_length, 0, SEEK_CUR) | ||||||||||||||||||||||||||||||||||||||||||
| 858 | # if $extra_length || $comment_length || $filename_length; | ||||||||||||||||||||||||||||||||||||||||||
| 859 | # push @CD, $compressedLength ; | ||||||||||||||||||||||||||||||||||||||||||
| 860 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 861 | # | ||||||||||||||||||||||||||||||||||||||||||
| 862 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 863 | # | ||||||||||||||||||||||||||||||||||||||||||
| 864 | #sub findCentralDirectoryOffset | ||||||||||||||||||||||||||||||||||||||||||
| 865 | #{ | ||||||||||||||||||||||||||||||||||||||||||
| 866 | # my $self = shift ; | ||||||||||||||||||||||||||||||||||||||||||
| 867 | # | ||||||||||||||||||||||||||||||||||||||||||
| 868 | # # Most common use-case is where there is no comment, so | ||||||||||||||||||||||||||||||||||||||||||
| 869 | # # know exactly where the end of central directory record | ||||||||||||||||||||||||||||||||||||||||||
| 870 | # # should be. | ||||||||||||||||||||||||||||||||||||||||||
| 871 | # | ||||||||||||||||||||||||||||||||||||||||||
| 872 | # $self->smarkSeek(-22, 0, SEEK_END) ; | ||||||||||||||||||||||||||||||||||||||||||
| 873 | # | ||||||||||||||||||||||||||||||||||||||||||
| 874 | # my $buffer; | ||||||||||||||||||||||||||||||||||||||||||
| 875 | # $self->smartReadExact(\$buffer, 22) ; | ||||||||||||||||||||||||||||||||||||||||||
| 876 | # | ||||||||||||||||||||||||||||||||||||||||||
| 877 | # my $zip64 = 0; | ||||||||||||||||||||||||||||||||||||||||||
| 878 | # my $centralDirOffset ; | ||||||||||||||||||||||||||||||||||||||||||
| 879 | # if ( unpack("V", $buffer) == ZIP_END_CENTRAL_HDR_SIG ) { | ||||||||||||||||||||||||||||||||||||||||||
| 880 | # $centralDirOffset = unpack ("V", substr($buffer, 16, 2)); | ||||||||||||||||||||||||||||||||||||||||||
| 881 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 882 | # else { | ||||||||||||||||||||||||||||||||||||||||||
| 883 | # die "xxxx"; | ||||||||||||||||||||||||||||||||||||||||||
| 884 | # } | ||||||||||||||||||||||||||||||||||||||||||
| 885 | # | ||||||||||||||||||||||||||||||||||||||||||
| 886 | # return $centralDirOffset ; | ||||||||||||||||||||||||||||||||||||||||||
| 887 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 888 | # | ||||||||||||||||||||||||||||||||||||||||||
| 889 | #sub is84BitCD | ||||||||||||||||||||||||||||||||||||||||||
| 890 | #{ | ||||||||||||||||||||||||||||||||||||||||||
| 891 | # # TODO | ||||||||||||||||||||||||||||||||||||||||||
| 892 | # my $self = shift ; | ||||||||||||||||||||||||||||||||||||||||||
| 893 | #} | ||||||||||||||||||||||||||||||||||||||||||
| 894 | |||||||||||||||||||||||||||||||||||||||||||
| 895 | |||||||||||||||||||||||||||||||||||||||||||
| 896 | sub skip | ||||||||||||||||||||||||||||||||||||||||||
| 897 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
skip: not called CC=2 SCAR=12.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 898 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 899 | 0 | my $size = shift; | |||||||||||||||||||||||||||||||||||||||||
| 900 | |||||||||||||||||||||||||||||||||||||||||||
| 901 | 83 | ▶ | use Fcntl qw(SEEK_CUR); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 902 | 0 | ▶ | if (ref $size eq 'U64') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 0 | $self->smartSeek($size->get64bit(), SEEK_CUR); | |||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 906 | 0 | $self->smartSeek($size, SEEK_CUR); | |||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||
| 908 | |||||||||||||||||||||||||||||||||||||||||||
| 909 | } | ||||||||||||||||||||||||||||||||||||||||||
| 910 | |||||||||||||||||||||||||||||||||||||||||||
| 911 | |||||||||||||||||||||||||||||||||||||||||||
| 912 | sub scanCentralDirectory | ||||||||||||||||||||||||||||||||||||||||||
| 913 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
scanCentralDirectory: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 914 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 915 | |||||||||||||||||||||||||||||||||||||||||||
| 916 | 0 | my $here = $self->tell(); | |||||||||||||||||||||||||||||||||||||||||
| 917 | |||||||||||||||||||||||||||||||||||||||||||
| 918 | # Use cases | ||||||||||||||||||||||||||||||||||||||||||
| 919 | # 1 32-bit CD | ||||||||||||||||||||||||||||||||||||||||||
| 920 | # 2 64-bit CD | ||||||||||||||||||||||||||||||||||||||||||
| 921 | |||||||||||||||||||||||||||||||||||||||||||
| 922 | 0 | my @CD = (); | |||||||||||||||||||||||||||||||||||||||||
| 923 | 0 | my $offset = $self->findCentralDirectoryOffset(); | |||||||||||||||||||||||||||||||||||||||||
| 924 | |||||||||||||||||||||||||||||||||||||||||||
| 925 | return () | ||||||||||||||||||||||||||||||||||||||||||
| 926 | 0 | ▶ | if ! defined $offset; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 927 | |||||||||||||||||||||||||||||||||||||||||||
| 928 | 0 | $self->smarkSeek($offset, 0, SEEK_SET) ; | |||||||||||||||||||||||||||||||||||||||||
| 929 | |||||||||||||||||||||||||||||||||||||||||||
| 930 | # Now walk the Central Directory Records | ||||||||||||||||||||||||||||||||||||||||||
| 931 | 0 | my $buffer ; | |||||||||||||||||||||||||||||||||||||||||
| 932 | 0 | ▶ | while ($self->smartReadExact(\$buffer, 46) && | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->smartReadExact(\$buffer, 46) and unpack("V", $buffer) == 33639248
MC/DC0%0/2
$self->smartReadExact(\$buffer, 46) and unpack("V", $buffer) == 33639248
$self->smartReadExact(\$buffer, 46)
unpack("V", $buffer) == 33639248
Truth table0%0/3
A and B
A= $self->smartReadExact(\$buffer, 46)B= unpack("V", $buffer) == 33639248
| |||||||||||||||||||||||||||||||||||||||||||
| 933 | unpack("V", $buffer) == ZIP_CENTRAL_HDR_SIG) { | ||||||||||||||||||||||||||||||||||||||||||
| 934 | |||||||||||||||||||||||||||||||||||||||||||
| 935 | 0 | my $compressedLength = unpack("V", substr($buffer, 20, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 936 | 0 | my $uncompressedLength = unpack("V", substr($buffer, 24, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 937 | 0 | my $filename_length = unpack("v", substr($buffer, 28, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 938 | 0 | my $extra_length = unpack("v", substr($buffer, 30, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 939 | 0 | my $comment_length = unpack("v", substr($buffer, 32, 2)); | |||||||||||||||||||||||||||||||||||||||||
| 940 | |||||||||||||||||||||||||||||||||||||||||||
| 941 | 0 | $self->skip($filename_length ) ; | |||||||||||||||||||||||||||||||||||||||||
| 942 | |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my $v64 = U64->new( $compressedLength ); | |||||||||||||||||||||||||||||||||||||||||
| 944 | |||||||||||||||||||||||||||||||||||||||||||
| 945 | 0 | ▶ | if (U64::full32 $compressedLength ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | $self->smartReadExact(\$buffer, $extra_length) ; | |||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | ▶ | die "xxx $offset $comment_length $filename_length $extra_length" . length($buffer) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 948 | if length($buffer) != $extra_length; | ||||||||||||||||||||||||||||||||||||||||||
| 949 | 0 | my $got = $self->get64Extra($buffer, U64::full32 $uncompressedLength); | |||||||||||||||||||||||||||||||||||||||||
| 950 | |||||||||||||||||||||||||||||||||||||||||||
| 951 | # If not Zip64 extra field, assume size is 0xFFFFFFFF | ||||||||||||||||||||||||||||||||||||||||||
| 952 | 0 | ▶ | $v64 = $got if defined $got; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 953 | } | ||||||||||||||||||||||||||||||||||||||||||
| 954 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 955 | 0 | $self->skip($extra_length) ; | |||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||
| 957 | |||||||||||||||||||||||||||||||||||||||||||
| 958 | 0 | $self->skip($comment_length ) ; | |||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | 0 | push @CD, $v64 ; | |||||||||||||||||||||||||||||||||||||||||
| 961 | } | ||||||||||||||||||||||||||||||||||||||||||
| 962 | |||||||||||||||||||||||||||||||||||||||||||
| 963 | 0 | $self->smartSeek($here, 0, SEEK_SET) ; | |||||||||||||||||||||||||||||||||||||||||
| 964 | |||||||||||||||||||||||||||||||||||||||||||
| 965 | 0 | return @CD; | |||||||||||||||||||||||||||||||||||||||||
| 966 | } | ||||||||||||||||||||||||||||||||||||||||||
| 967 | |||||||||||||||||||||||||||||||||||||||||||
| 968 | sub get64Extra | ||||||||||||||||||||||||||||||||||||||||||
| 969 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get64Extra: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 970 | 0 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | 0 | my $buffer = shift; | |||||||||||||||||||||||||||||||||||||||||
| 973 | 0 | my $is_uncomp = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 974 | |||||||||||||||||||||||||||||||||||||||||||
| 975 | 0 | my $extra = IO::Compress::Zlib::Extra::findID(0x0001, $buffer); | |||||||||||||||||||||||||||||||||||||||||
| 976 | |||||||||||||||||||||||||||||||||||||||||||
| 977 | 0 | ▶ | if (! defined $extra) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 978 | { | ||||||||||||||||||||||||||||||||||||||||||
| 979 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||
| 980 | } | ||||||||||||||||||||||||||||||||||||||||||
| 981 | else | ||||||||||||||||||||||||||||||||||||||||||
| 982 | { | ||||||||||||||||||||||||||||||||||||||||||
| 983 | 0 | ▶ | my $u64 = U64::newUnpack_V64(substr($extra, $is_uncomp ? 8 : 0)) ; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | 0 | return $u64; | |||||||||||||||||||||||||||||||||||||||||
| 985 | } | ||||||||||||||||||||||||||||||||||||||||||
| 986 | } | ||||||||||||||||||||||||||||||||||||||||||
| 987 | |||||||||||||||||||||||||||||||||||||||||||
| 988 | sub offsetFromZip64 | ||||||||||||||||||||||||||||||||||||||||||
| 989 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
offsetFromZip64: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 990 | 0 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | my $here = shift; | |||||||||||||||||||||||||||||||||||||||||
| 992 | |||||||||||||||||||||||||||||||||||||||||||
| 993 | 0 | ▶ | $self->smartSeek($here - 20, 0, SEEK_SET) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | or die "xx $!" ; | ||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||
| 996 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | my $got = 0; | |||||||||||||||||||||||||||||||||||||||||
| 998 | 0 | ▶ | $self->smartReadExact(\$buffer, 20) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 999 | or die "xxx $here $got $!" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1000 | |||||||||||||||||||||||||||||||||||||||||||
| 1001 | 0 | ▶ | if ( unpack("V", $buffer) == ZIP64_END_CENTRAL_LOC_HDR_SIG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1002 | 0 | my $cd64 = U64::Value_VV64 substr($buffer, 8, 8); | |||||||||||||||||||||||||||||||||||||||||
| 1003 | |||||||||||||||||||||||||||||||||||||||||||
| 1004 | 0 | $self->smartSeek($cd64, 0, SEEK_SET) ; | |||||||||||||||||||||||||||||||||||||||||
| 1005 | |||||||||||||||||||||||||||||||||||||||||||
| 1006 | 0 | ▶ | $self->smartReadExact(\$buffer, 4) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1007 | or die "xxx" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1008 | |||||||||||||||||||||||||||||||||||||||||||
| 1009 | 0 | ▶ | if ( unpack("V", $buffer) == ZIP64_END_CENTRAL_REC_HDR_SIG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | |||||||||||||||||||||||||||||||||||||||||||
| 1011 | 0 | ▶ | $self->smartReadExact(\$buffer, 8) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1012 | or die "xxx" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1013 | 0 | my $size = U64::Value_VV64($buffer); | |||||||||||||||||||||||||||||||||||||||||
| 1014 | 0 | ▶ | $self->smartReadExact(\$buffer, $size) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1015 | or die "xxx" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||
| 1017 | 0 | my $cd64 = U64::Value_VV64 substr($buffer, 36, 8); | |||||||||||||||||||||||||||||||||||||||||
| 1018 | |||||||||||||||||||||||||||||||||||||||||||
| 1019 | 0 | return $cd64 ; | |||||||||||||||||||||||||||||||||||||||||
| 1020 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1021 | |||||||||||||||||||||||||||||||||||||||||||
| 1022 | 0 | die "zzz"; | |||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | |||||||||||||||||||||||||||||||||||||||||||
| 1025 | 0 | die "zzz"; | |||||||||||||||||||||||||||||||||||||||||
| 1026 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | |||||||||||||||||||||||||||||||||||||||||||
| 1028 | 83 | ▶ | use constant Pack_ZIP_END_CENTRAL_HDR_SIG => pack("V", ZIP_END_CENTRAL_HDR_SIG); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1029 | |||||||||||||||||||||||||||||||||||||||||||
| 1030 | sub findCentralDirectoryOffset | ||||||||||||||||||||||||||||||||||||||||||
| 1031 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
findCentralDirectoryOffset: not called CC=9 SCAR=45.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 1032 | 0 | my $self = shift ; | |||||||||||||||||||||||||||||||||||||||||
| 1033 | |||||||||||||||||||||||||||||||||||||||||||
| 1034 | # Most common use-case is where there is no comment, so | ||||||||||||||||||||||||||||||||||||||||||
| 1035 | # know exactly where the end of central directory record | ||||||||||||||||||||||||||||||||||||||||||
| 1036 | # should be. | ||||||||||||||||||||||||||||||||||||||||||
| 1037 | |||||||||||||||||||||||||||||||||||||||||||
| 1038 | 0 | $self->smartSeek(-22, 0, SEEK_END) ; | |||||||||||||||||||||||||||||||||||||||||
| 1039 | 0 | my $here = $self->tell(); | |||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||
| 1041 | 0 | my $buffer; | |||||||||||||||||||||||||||||||||||||||||
| 1042 | 0 | ▶ | $self->smartReadExact(\$buffer, 22) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1043 | or die "xxx" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | |||||||||||||||||||||||||||||||||||||||||||
| 1045 | 0 | my $zip64 = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1046 | 0 | my $centralDirOffset ; | |||||||||||||||||||||||||||||||||||||||||
| 1047 | 0 | ▶ | if ( unpack("V", $buffer) == ZIP_END_CENTRAL_HDR_SIG ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1048 | 0 | $centralDirOffset = unpack("V", substr($buffer, 16, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1050 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 1051 | 0 | $self->smartSeek(0, 0, SEEK_END) ; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||
| 1053 | 0 | my $fileLen = $self->tell(); | |||||||||||||||||||||||||||||||||||||||||
| 1054 | 0 | my $want = 0 ; | |||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | 0 | while(1) { | |||||||||||||||||||||||||||||||||||||||||
| 1057 | 0 | $want += 1024; | |||||||||||||||||||||||||||||||||||||||||
| 1058 | 0 | my $seekTo = $fileLen - $want; | |||||||||||||||||||||||||||||||||||||||||
| 1059 | 0 | ▶ | if ($seekTo < 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1060 | 0 | $seekTo = 0; | |||||||||||||||||||||||||||||||||||||||||
| 1061 | 0 | $want = $fileLen ; | |||||||||||||||||||||||||||||||||||||||||
| 1062 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1063 | 0 | ▶ | $self->smartSeek( $seekTo, 0, SEEK_SET) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1064 | or die "xxx $!" ; | ||||||||||||||||||||||||||||||||||||||||||
| 1065 | 0 | my $got; | |||||||||||||||||||||||||||||||||||||||||
| 1066 | 0 | ▶ | $self->smartReadExact($buffer, $want) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1067 | or die "xxx " ; | ||||||||||||||||||||||||||||||||||||||||||
| 1068 | 0 | my $pos = rindex( $buffer, Pack_ZIP_END_CENTRAL_HDR_SIG); | |||||||||||||||||||||||||||||||||||||||||
| 1069 | |||||||||||||||||||||||||||||||||||||||||||
| 1070 | 0 | ▶ | if ($pos >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1071 | #$here = $self->tell(); | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | 0 | $here = $seekTo + $pos ; | |||||||||||||||||||||||||||||||||||||||||
| 1073 | 0 | $centralDirOffset = unpack("V", substr($buffer, $pos + 16, 4)); | |||||||||||||||||||||||||||||||||||||||||
| 1074 | 0 | last ; | |||||||||||||||||||||||||||||||||||||||||
| 1075 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | return undef | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | 0 | ▶ | if $want == $fileLen; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1079 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | |||||||||||||||||||||||||||||||||||||||||||
| 1082 | 0 | ▶ | $centralDirOffset = $self->offsetFromZip64($here) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1083 | if U64::full32 $centralDirOffset ; | ||||||||||||||||||||||||||||||||||||||||||
| 1084 | |||||||||||||||||||||||||||||||||||||||||||
| 1085 | 0 | return $centralDirOffset ; | |||||||||||||||||||||||||||||||||||||||||
| 1086 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1087 | |||||||||||||||||||||||||||||||||||||||||||
| 1088 | 83 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 1089 | |||||||||||||||||||||||||||||||||||||||||||
| 1090 | __END__ | ||||||||||||||||||||||||||||||||||||||||||