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