[Bps-public-commit] r14128 - in Data-Plist: .
alexmv at bestpractical.com
alexmv at bestpractical.com
Tue Jul 15 17:10:52 EDT 2008
Author: alexmv
Date: Tue Jul 15 17:10:50 2008
New Revision: 14128
Modified:
Data-Plist/ (props changed)
Data-Plist/lib/Data/Plist/BinaryReader.pm
Log:
r34193 at kohr-ah: chmrr | 2008-07-15 17:08:55 -0400
* Some more safeguarding
Modified: Data-Plist/lib/Data/Plist/BinaryReader.pm
==============================================================================
--- Data-Plist/lib/Data/Plist/BinaryReader.pm (original)
+++ Data-Plist/lib/Data/Plist/BinaryReader.pm Tue Jul 15 17:10:50 2008
@@ -4,6 +4,7 @@
use warnings;
use base qw/Data::Plist::Reader/;
+use Data::Plist;
use Encode qw(decode);
use Fcntl qw(:seek);
@@ -222,9 +223,13 @@
}
# get trailer
- seek( $self->{fh}, -32, SEEK_END );
+ eval {seek( $self->{fh}, -32, SEEK_END )}
+ or die "Read of plist trailer failed\n";
my $end = tell( $self->{fh} );
+ die "Read of plist trailer failed\n"
+ unless $end >= 8;
+
unless ( read( $self->{fh}, $buf, 32 ) == 32 ) {
die "Read of plist trailer failed\n";
}
@@ -269,7 +274,14 @@
}
# Catch invalid offset addresses in the offset table
- if ( grep { $_ < 8 or $_ >= $end } @Offsets ) {
+ if (grep {
+ $_ < 8
+ or $_ >= $end
+ or ($_ >= $OffsetTableOffset
+ and $_ < $OffsetTableOffset + $NumObjects * $OffsetSize )
+ } @Offsets
+ )
+ {
die "Invalid address in offset table\n";
}
More information about the Bps-public-commit
mailing list