Plist/BinaryReader.pm

filter: Statementstmt 96.3% 158 / 164 Branchbran 81.0% 60 / 74 Conditioncond 84.8% 28 / 33 MC/DCmcdc 73.6% 14 / 19 Subroutinesub 100% 21 / 21 Podpod 100% 14 / 14 totaltotal 90.7% 295 / 325 CC 50 SCAR 22.3
CC
50
Cov
91%
open_fh
21.2
binary_read
8.1
read_integer
6.0
CRAP 9.3
« Plist.pm ↑ Summary Plist/Writer.pm »
1 =head1 NAME
2  
3 Data::Plist::BinaryReader - Creates Data::Plists from binary files
4  
5 =head1 SYNOPSIS
6  
7 # Create new
8 my $read = Data::Plist::BinaryReader->new;
9  
10 # Read from a string
11 my $plist = $read->open_string($binarystring);
12  
13 # Read from a binary file
14 $plist = $read->open_fh($filename);
15  
16 =head1 DESCRIPTION
17  
18 C<Data::Plist::BinaryReader> takes data formatted as one of
19 Apple's binary property lists, either from a string or a
20 filehandle and returns it as a C<Data::Plist>.
21  
22 =cut
23  
24 package Data::Plist::BinaryReader;
25  
26 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 4 ▶use base qw/Data::Plist::Reader/;
Subroutine BEGIN: called CC=1 SCAR=0.0
30 4 ▶use Data::Plist;
Subroutine BEGIN: called CC=1 SCAR=0.0
31  
32 4 ▶use Encode qw(decode);
Subroutine BEGIN: called CC=1 SCAR=0.0
33 4 ▶use Fcntl qw(:seek);
Subroutine BEGIN: called CC=1 SCAR=0.0
34 4 ▶use Math::BigInt;
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36 =head1 METHODS
37  
38 =head2 read_misc $type
39  
40 Takes an integer C<$type> indicating which misc is being
41 read. Returns an array containing the type of misc and its
42 associated integer.
43  
44 =cut
45  
46 10 ▶sub read_misc {
Subroutine read_misc: called CC=5 SCAR=16.2
Pod documented
47 10 my $self = shift;
48  
49 10 my ($type) = @_;
50 10 ▶ if ( $type == 0 ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($type == 0) { } 4 6 10
elsif ($type == 8) { } 4 2 6
elsif ($type == 9) { } 1 1 2
elsif ($type == 15) { } 1 0 1
51 4 return [ "null", 0 ];
52 } elsif ( $type == 8 ) {
53 4 return [ "false", 0 ];
54 } elsif ( $type == 9 ) {
55 1 return [ "true", 1 ];
56 } elsif ( $type == 15 ) {
57 1 return [ "fill", 15 ];
58 } else {
59 0 return [ "???", $type ];
60 }
61 }
62  
63 =head2 read_integer $size
64  
65 Takes an integer C<$size> indicating number of bytes needed
66 to encode the integer (2**C<$size> = number of
67 bytes). Reads that number of bytes from the filehandle and
68 unpacks it. Returns an array containing the string
69 "integer" and the value of the integer read from the
70 filehandle.
71  
72 =cut
73  
74 355 ▶sub read_integer {
Subroutine read_integer: called CC=6 SCAR=18.0
Pod documented
75 355 my $self = shift;
76 355 my ($size) = @_;
77  
78 355 my ( $buf, $val );
79 355 read( $self->{fh}, $buf, 1 << $size );
80 355 ▶ if ( $size == 0 ) { # 8 bit
Branch: 4 branches
BranchTrueFalseTotal
if ($size == 0) { } 300 55 355
elsif ($size == 1) { } 48 7 55
elsif ($size == 2) { } 5 2 7
elsif ($size == 3) { } 2 0 2
81 300 $val = unpack( "C", $buf );
82 } elsif ( $size == 1 ) { # 16 bit
83 48 $val = unpack( "n", $buf );
84 } elsif ( $size == 2 ) { # 32 bit
85 5 $val = unpack( "N", $buf );
86 } elsif ( $size == 3 ) { # 64 bit
87  
88 2 my ( $hw, $lw ) = unpack( "NN", $buf );
89 2 $val = Math::BigInt->new($hw)->blsft(32)->bior($lw);
90 2 ▶ if ( $val->bcmp( Math::BigInt->new(2)->bpow(63) ) > 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val->bcmp("Math::BigInt"->new(2)->bpow(63)) > 0) 1 1 2
91 1 $val -= Math::BigInt->new(2)->bpow(64);
92 }
93 } else {
94 0 die "Invalid size for integer ($size)";
95 }
96  
97 355 return [ "integer", $val ];
98 }
99  
100 =head2 read_real $size
101  
102 Takes an integer C<$size> indicating the number of bytes
103 needed to encode the float (see L</read_integer>). Reads
104 that number of bytes from the filehandle and unpacks
105 it. The number of bytes is limited to 4 and 8. Returns an
106 array containing the string "array" and the float read from
107 the filehandle.
108  
109 =cut
110  
111 4 ▶sub read_real {
Subroutine read_real: called CC=3 SCAR=11.8
Pod documented
112 4 my $self = shift;
113 4 my ($size) = @_;
114  
115 4 my ( $buf, $val );
116 4 read( $self->{fh}, $buf, 1 << $size );
117 4 ▶ if ( $size == 2 ) { # 32 bit
Branch: 2 branches
BranchTrueFalseTotal
if ($size == 2) { } 0 4 4
elsif ($size == 3) { } 4 0 4
118 0 $val = unpack( "f", reverse $buf );
119 } elsif ( $size == 3 ) { # 64 bit
120 4 $val = unpack( "d", reverse $buf );
121 } else {
122 0 die "Invalid size for real ($size)";
123 }
124  
125 4 return [ "real", $val ];
126 }
127  
128 =head2 read_date $size
129  
130 Takes an integer C<$size>, checks to ensure that it's
131 within the proper boundaries, and then passes it to
132 L</read_real> to be dealt with, since dates are just stored
133 as floats. Returns an array containing the string "date"
134 and the date read from the filehandle.
135  
136 =cut
137  
138 1 ▶sub read_date {
Subroutine read_date: called CC=3 SCAR=12.0
Pod documented
139 1 my $self = shift;
140 1 my ($size) = @_;
141 1 ▶ die "Invalid size for date ($size)"
Branch: 1 branch
BranchTrueFalseTotal
if $size > 3 or $size < 2 0 1 1
Condition33%1/3
$size > 3 or $size < 2
l!l&&r!l&&!r
001
MC/DC0%0/2
$size > 3 or $size < 2
$size > 3 $size < 2
Truth table33%1/3
A or B
A= $size > 3B= $size < 2
ABresult
1X1
011
000
142 if ( $size > 3 or $size < 2 );
143  
144 # Dates are just stored as floats
145 1 return [ "date", $self->read_real($size)->[1] ];
146 }
147  
148 =head2 read_data $size
149  
150 Takes an integer C<$size>, indicating the number of bytes
151 of binary data stored and reads them from the
152 filehandle. Checks if the bytes are actually another binary
153 plist and unpacks it if so. Returns an array containing the
154 string "data" and the binary data read from the filehandle.
155  
156 =cut
157  
158 6 ▶sub read_data {
Subroutine read_data: called CC=3 SCAR=11.1
Pod documented
159 6 my $self = shift;
160 6 my ($size) = @_;
161  
162 6 my $buf;
163 6 read( $self->{fh}, $buf, $size );
164  
165 # Binary data is often a binary plist! Unpack it.
166 6 ▶ if ( $buf =~ /^bplist00/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($buf =~ /^bplist00/) 2 4 6
167 2 ▶ $buf = eval { ( ref $self )->open_string($buf) } || $buf;
Condition33%1/3
eval { do { ref($self)->open_string($buf) } } || $buf
l!l&&r!l&&!r
200
MC/DC0%0/2
eval { do { ref($self)->open_string($buf) } } || $buf
eval { do { ref($self)->open_string($buf) } } $buf
Truth table33%1/3
A || B
A= eval { do { ref($self)->open_string($buf) } }B= $buf
ABresult
1X1
011
000
168 }
169  
170 6 return [ "data", $buf ];
171 }
172  
173 =head2 read_string $size
174  
175 Takes an integer C<$size> indicating the number of bytes
176 used to encode the UTF-8 string stored and reads them from
177 the filehandle. Marks them as Unicode and returns an array
178 containing the string "string" and the string read from the
179 filehandle.
180  
181 =cut
182  
183 108 ▶sub read_string {
Subroutine read_string: called CC=1 SCAR=0.0
Pod documented
184 108 my $self = shift;
185 108 my ($size) = @_;
186  
187 108 my $buf;
188 108 read( $self->{fh}, $buf, $size );
189  
190 108 $buf = pack "U0C*", unpack "C*", $buf; # mark as Unicode
191  
192 108 return [ "string", $buf ];
193 }
194  
195 =head2 read_ustring
196  
197 Takes an integer C<$size> indicating the number of bytes
198 used to encode the UTF-16 string stored and reads them from
199 the filehandle. Returns an array containing the string
200 "ustring" and the string read from the filehandle.
201  
202 =cut
203  
204 2 ▶sub read_ustring {
Subroutine read_ustring: called CC=1 SCAR=0.0
Pod documented
205 2 my $self = shift;
206 2 my ($size) = @_;
207  
208 2 my $buf;
209 2 read( $self->{fh}, $buf, 2 * $size );
210  
211 2 return [ "ustring", decode( "UTF-16BE", $buf ) ];
212 }
213  
214 =head2 read_refs $count
215  
216 Takes an integer C<$count> indicating the number of
217 references in either a dict or an array. Returns the
218 references pointing to the locations fo the contents of the
219 dict or array.
220  
221 =cut
222  
223 71 ▶sub read_refs {
Subroutine read_refs: called CC=2 SCAR=6.9
Pod documented
224 71 my $self = shift;
225 71 my ($count) = @_;
226 71 my $buf;
227 71 read( $self->{fh}, $buf, $count * $self->{refsize} );
228 71 ▶ return unpack( ( $self->{refsize} == 1 ? "C*" : "n*" ), $buf );
Branch: 1 branch
BranchTrueFalseTotal
$self->{'refsize'} == 1 ? : 70 1 71
229 }
230  
231 =head2 read_array $size
232  
233 Takes an integer C<$size> indicating the number of objects
234 that are contained in the array. Returns an array
235 containing the string "array" and the references pointing
236 to the location of the contents of the array in the file.
237  
238 =cut
239  
240 17 ▶sub read_array {
Subroutine read_array: called CC=1 SCAR=0.0
Pod documented
241 17 my $self = shift;
242 17 my ($size) = @_;
243  
244 return [
245 17 "array", [ map { $self->binary_read($_) } $self->read_refs($size) ]
246 ];
247 }
248  
249 =head2 read_dict $size
250  
251 Takes an integer C<$size> indicating the number of
252 key-value pairs contained in the dict. Returns an array
253 containing the string "dict" and the references pointing to
254 the location of the key-value pairs of the dict in the
255 file.
256  
257 =cut
258  
259 27 ▶sub read_dict {
Subroutine read_dict: called CC=3 SCAR=11.0
Pod documented
260 27 my $self = shift;
261 27 my ($size) = @_;
262 27 my %dict;
263  
264 # read keys
265 27 my @keys = $self->read_refs($size);
266 27 my @objs = $self->read_refs($size);
267  
268 27 for my $j ( 0 .. $#keys ) {
269 62 my $key = $self->binary_read( $keys[$j] );
270 62 ▶ die "Key of hash isn't a string!" unless $key->[0] eq "string";
Branch: 1 branch
BranchTrueFalseTotal
unless $key->[0] eq "string" 0 62 62
271 62 $key = $key->[1];
272 62 my $obj = $self->binary_read( $objs[$j] );
273 62 $dict{$key} = $obj;
274 }
275  
276 27 return [ "dict", \%dict ];
277 }
278  
279 =head2 read_uid $size
280  
281 Takes an integer C<$size> indicating number of bytes needed
282 to encode the uid (2**C<$size> = number of bytes) and then
283 passes it to L</read_integer> to be dealt with, since uids
284 are stored identically to integers. Returns an array
285 containing the string "uid" and the uid read from the
286 filehandle.
287  
288 =cut
289  
290 19 ▶sub read_uid {
Subroutine read_uid: called CC=1 SCAR=0.0
Pod documented
291 19 my $self = shift;
292 19 my ($size) = @_;
293  
294 # UIDs are stored internally identically to ints
295 19 my $v = $self->read_integer($size)->[1];
296 19 return [ UID => $v ];
297 }
298  
299 =head2 binary_read $objNum
300  
301 Takes an integer indicating the offset number of the
302 current object C<$objNum> and checks to make sure it's
303 valid. Reads the object's type and size and then matches
304 the type to its read method. Passes the size to the correct
305 method and returns what that method returns.
306  
307 =cut
308  
309 529 ▶sub binary_read {
Subroutine binary_read: called CC=8 SCAR=21.0
Pod documented
310 529 my $self = shift;
311 529 my ($objNum) = @_;
312  
313 529 ▶ if ( defined $objNum ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $objNum) 508 21 529
314 die "Bad offset: $objNum"
315 508 ▶ unless $objNum < @{ $self->{offsets} };
Branch: 1 branch
BranchTrueFalseTotal
unless $objNum < @{$self->{"offsets"};} 0 508 508
316 508 seek( $self->{fh}, $self->{offsets}[$objNum], SEEK_SET );
317 }
318  
319 # get object type/size
320 529 my $buf;
321 529 ▶ read( $self->{fh}, $buf, 1 )
Branch: 1 branch
BranchTrueFalseTotal
read $self->{"fh"}, $buf, 1 or die "Can't read type byte: $!\cHyte:" 529 0 529
322 or die "Can't read type byte: $!\byte:";
323  
324 529 my $size = unpack( "C*", $buf ) & 0x0F; # Low nybble is size
325 529 my $objType = unpack( "C*", $buf ) >> 4; # High nybble is type
326 529 ▶ $size = $self->binary_read->[1]
Branch: 1 branch
BranchTrueFalseTotal
if $objType != 0 and $size == 15 21 508 529
Condition100%3/3
$objType != 0 and $size == 15
!ll&&!rl&&r
1049821
MC/DC100%2/2
$objType != 0 and $size == 15
$objType != 0 $size == 15
Truth table100%3/3
A and B
A= $objType != 0B= $size == 15
ABresult
0X0
100
111
327 if $objType != 0 and $size == 15;
328  
329 529 my %types = (
330 0 => "misc",
331 1 => "integer",
332 2 => "real",
333 3 => "date",
334 4 => "data",
335 5 => "string",
336 6 => "ustring",
337 8 => "uid",
338 10 => "array",
339 13 => "dict",
340 );
341  
342 529 ▶ die "Unknown type $objType" unless $types{$objType};
Branch: 1 branch
BranchTrueFalseTotal
unless $types{$objType} 0 529 529
343 529 my $method = "read_" . $types{$objType};
344 529 ▶ die "Can't $method" unless $self->can($method);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->can($method) 0 529 529
345 529 return $self->$method($size);
346 }
347  
348 =head2 open_string $string
349  
350 Takes a string of binary information in Apple's binary
351 property list format C<$string>. Checks to ensure that it's
352 of the correct format and then passes its superclass's
353 L</open_string>. The error proofing is done because
354 seeking in in-memory filehandles can cause perl 5.8.8 to
355 explode with "Out of memory" or "panic: memory wrap".
356  
357 =cut
358  
359 53 ▶sub open_string {
Subroutine open_string: called CC=5 SCAR=16.1
Pod documented
360 53 my $self = shift;
361 53 my ($str) = @_;
362  
363 53 ▶ die "Not a binary plist file\n"
Branch: 1 branch
BranchTrueFalseTotal
unless length $str >= 8 and substr($str, 0, 8) eq "bplist00" 2 51 53
Condition100%3/3
length $str >= 8 and substr($str, 0, 8) eq "bplist00"
!ll&&!rl&&r
1151
MC/DC100%2/2
length $str >= 8 and substr($str, 0, 8) eq "bplist00"
length $str >= 8 substr($str, 0, 8) eq "bplist00"
Truth table100%3/3
A and B
A= length $str >= 8B= substr($str, 0, 8) eq "bplist00"
ABresult
0X0
100
111
364 unless length $str >= 8 and substr( $str, 0, 8 ) eq "bplist00";
365 51 ▶ die "Read of plist trailer failed\n"
Branch: 1 branch
BranchTrueFalseTotal
unless length $str >= 40 4 47 51
366 unless length $str >= 40;
367 47 ▶ die "Invalid top object identifier\n"
Branch: 1 branch
BranchTrueFalseTotal
unless length $str > 40 1 46 47
368 unless length $str > 40;
369  
370 46 return $self->SUPER::open_string($str);
371 }
372  
373 =head2 open_fh $filehandle
374  
375 Used for reading binary data from a filehandle
376 C<$filehandle> rather than a string. Opens the filehandle
377 and sanity checks the header, trailer and offset
378 table. Returns a C<Data::Plist> containing the top object
379 of the filehandle after it's been passed to
380 L</binary_read>.
381  
382 =cut
383  
384 51 ▶sub open_fh {
Subroutine open_fh: called CC=21 SCAR=30.6
Pod documented
385 51 my $self = shift;
386 51 ▶ $self = $self->new() unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 2 49 51
387  
388 51 my ($fh) = @_;
389  
390 51 my $buf;
391 51 $self->{fh} = $fh;
392 51 seek( $self->{fh}, 0, SEEK_SET );
393 51 read( $self->{fh}, $buf, 8 );
394 51 ▶ unless ( $buf eq "bplist00" ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($buf eq "bplist00") 1 50 51
395 1 die "Not a binary plist file\n";
396 }
397  
398 # get trailer
399 50 ▶ eval { seek( $self->{fh}, -32, SEEK_END ) }
Branch: 1 branch
BranchTrueFalseTotal
eval { do { seek $self->{"fh"}, -32, 2 } } or die "Read of plist trailer failed\n" 50 0 50
400 or die "Read of plist trailer failed\n";
401 50 my $end = tell( $self->{fh} );
402  
403 50 ▶ die "Read of plist trailer failed\n"
Branch: 1 branch
BranchTrueFalseTotal
unless $end >= 8 0 50 50
404 unless $end >= 8;
405  
406 50 ▶ unless ( read( $self->{fh}, $buf, 32 ) == 32 ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (read($self->{"fh"}, $buf, 32) == 32) 0 50 50
407 0 die "Read of plist trailer failed\n";
408 }
409 50 local $self->{refsize};
410 50 my ( $OffsetSize, $NumObjects, $TopObject, $OffsetTableOffset );
411 50 ( $OffsetSize, $self->{refsize}, $NumObjects, $TopObject,
412 $OffsetTableOffset
413 ) = unpack "x6CC(x4N)3", $buf;
414  
415 # Sanity check the trailer
416 50 ▶ if ( $OffsetSize < 1 or $OffsetSize > 4 ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($OffsetSize < 1 or $OffsetSize > 4) { } 2 48 50
elsif ($self->{'refsize'} < 1 or $self->{'refsize'} > 2) { } 2 46 48
elsif (2 ** (8 * $self->{'refsize'}) < $NumObjects) { } 1 45 46
elsif ($TopObject >= $NumObjects) { } 1 44 45
elsif ($OffsetTableOffset < 8 or $OffsetTableOffset > $end or $OffsetTableOffset + $NumObjects * $OffsetSize > $end) { } 2 42 44
Condition100%3/3
$OffsetSize < 1 or $OffsetSize > 4
l!l&&r!l&&!r
1148
MC/DC100%2/2
$OffsetSize < 1 or $OffsetSize > 4
$OffsetSize < 1 $OffsetSize > 4
Truth table100%3/3
A or B
A= $OffsetSize < 1B= $OffsetSize > 4
ABresult
1X1
011
000
417 2 die "Invalid offset size\n";
418 ▶ } elsif ( $self->{refsize} < 1 or $self->{refsize} > 2 ) {
Condition100%3/3
$self->{"refsize"} < 1 or $self->{"refsize"} > 2
l!l&&r!l&&!r
1146
MC/DC100%2/2
$self->{"refsize"} < 1 or $self->{"refsize"} > 2
$self->{"refsize"} < 1 $self->{"refsize"} > 2
Truth table100%3/3
A or B
A= $self->{"refsize"} < 1B= $self->{"refsize"} > 2
ABresult
1X1
011
000
419 2 die "Invalid reference size\n";
420 } elsif ( 2**( 8 * $self->{refsize} ) < $NumObjects ) {
421 1 die
422 1 "Reference size (@{[$self->{refsize}]}) is too small for purported number of objects ($NumObjects)\n";
423 } elsif ( $TopObject >= $NumObjects ) {
424 1 die "Invalid top object identifier\n";
425 ▶ } elsif ( $OffsetTableOffset < 8
Condition83%5/6
$OffsetTableOffset < 8 or $OffsetTableOffset > $end or $OffsetTableOffset + $NumObjects * $OffsetSize > $end
l!l&&r!l&&!r
1142
$OffsetTableOffset < 8 or $OffsetTableOffset > $end
l!l&&r!l&&!r
1043
MC/DC66%2/3
$OffsetTableOffset < 8 or $OffsetTableOffset > $end or $OffsetTableOffset + $NumObjects * $OffsetSize > $end
$OffsetTableOffset < 8 $OffsetTableOffset > $end $OffsetTableOffset + $NumObjects * $OffsetSize > $end
Truth table75%3/4
A or B or C
A= $OffsetTableOffset < 8B= $OffsetTableOffset > $endC= $OffsetTableOffset + $NumObjects * $OffsetSize > $end
ABCresult
1XX1
01X1
0011
0000
426 or $OffsetTableOffset > $end
427 or $OffsetTableOffset + $NumObjects * $OffsetSize > $end )
428 {
429 2 die "Invalid offset table address (overlap with header or footer).";
430 }
431  
432 # get the offset table
433 42 seek( $fh, $OffsetTableOffset, SEEK_SET );
434  
435 42 my $offsetTable;
436 my $readSize
437 42 = read( $self->{fh}, $offsetTable, $NumObjects * $OffsetSize );
438 42 ▶ if ( $readSize != $NumObjects * $OffsetSize ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($readSize != $NumObjects * $OffsetSize) 0 42 42
439 0 die "Offset table read $readSize bytes, expected ",
440 $NumObjects * $OffsetSize;
441 }
442  
443 42 my @Offsets = unpack( [ "", "C*", "n*", "(H6)*", "N*" ]->[$OffsetSize],
444 $offsetTable );
445 42 ▶ if ( $OffsetSize == 3 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($OffsetSize == 3) 2 40 42
446 2 @Offsets = map { hex($_) } @Offsets;
447 }
448  
449 # Catch invalid offset addresses in the offset table
450 42 ▶ if (grep {
Branch: 1 branch
BranchTrueFalseTotal
if (grep {$_ < 8 or $_ >= $end or $_ >= $OffsetTableOffset and $_ < $OffsetTableOffset + $NumObjects * $OffsetSize;} @Offsets) 5 37 42
451 495 ▶ $_ < 8
Condition100%9/9
$_ < 8 || $_ >= $end || $_ >= $OffsetTableOffset && $_ < $OffsetTableOffset + $NumObjects * $OffsetSize
l!l&&r!l&&!r
32490
$_ < 8 or $_ >= $end
l!l&&r!l&&!r
21492
$_ >= $OffsetTableOffset and $_ < $OffsetTableOffset + $NumObjects * $OffsetSize
!ll&&!rl&&r
48912
MC/DC100%4/4
$_ < 8 || $_ >= $end || $_ >= $OffsetTableOffset && $_ < $OffsetTableOffset + $NumObjects * $OffsetSize
$_ < 8 $_ >= $end $_ >= $OffsetTableOffset $_ < $OffsetTableOffset + $NumObjects * $OffsetSize
Truth table100%5/5
A or B || C and D
A= $_ < 8B= $_ >= $endC= $_ >= $OffsetTableOffsetD= $_ < $OffsetTableOffset + $NumObjects * $OffsetSize
ABCDresult
1XXX1
01XX1
00111
000X0
00100
452 or $_ >= $end
453 or ($_ >= $OffsetTableOffset
454 and $_ < $OffsetTableOffset + $NumObjects * $OffsetSize )
455 } @Offsets
456 )
457 {
458 5 die "Invalid address in offset table\n";
459 }
460  
461 37 local $self->{offsets} = \@Offsets;
462  
463 37 my $top = $self->binary_read($TopObject);
464 37 close($fh);
465  
466 37 return Data::Plist->new( data => $top );
467 }
468  
469 4 1;
« Plist.pm ↑ Summary Plist/Writer.pm »