--- lib/Mac/AppleSingleDouble.pm.orig	2001-09-29 16:06:42.000000000 -0700
+++ lib/Mac/AppleSingleDouble.pm	2008-10-03 13:35:35.000000000 -0700
@@ -345,45 +345,71 @@
 
 sub _parse_finder_info
 {
-    my $this = shift;
-    my $finderinfo_raw = shift;
-    my(%finderinfo);
-
-    # based on page 7-76 of Inside Macintosh: Finder Interface
-    $finderinfo{'Type'} = substr($finderinfo_raw, 0, 4);
-    $finderinfo{'Creator'} = substr($finderinfo_raw, 4, 4);
-    $finderinfo{'Flags'} = unpack('n', substr($finderinfo_raw, 8, 2));
-    $finderinfo{'Location'} = unpack('nn', substr($finderinfo_raw, 10, 4));
-    $finderinfo{'Fldr'} = unpack('n', substr($finderinfo_raw, 14, 2));
-
-    # Finder Flags
-    $flagbits = unpack('B8', substr($finderinfo_raw, 8, 1)) .unpack('B8', substr($finderinfo_raw, 9, 1)) ;
-    #print "flagbits is $flagbits\n";
-    $finderinfo{'Label'} = unpack('C', pack('B8', '0'x5 . substr($flagbits, 12, 3)));
-    $finderinfo{'Color'} = $finderinfo{'Label'};
-    $finderinfo{'IsOnDesk'} = substr($flagbits, 15, 1);
-    $finderinfo{'IsShared'} = substr($flagbits, 9, 1);
-    $finderinfo{'HasBeenInited'} = substr($flagbits, 7, 1);
-    $finderinfo{'HasCustomIcon'} = substr($flagbits, 5, 1);
-    $finderinfo{'IsStationery'} = substr($flagbits, 4, 1);
-    $finderinfo{'NameLocked'} = substr($flagbits, 3, 1);
-    $finderinfo{'HasBundle'} = substr($flagbits, 2, 1);
-    $finderinfo{'IsInvisible'} = substr($flagbits, 1, 1);
-    $finderinfo{'IsAlias'} = substr($flagbits, 0, 1);    
-
-    # Extended Finder Info
-    $finderinfo{'IconID'} = unpack('n', substr($finderinfo_raw, 16, 2));
-    $finderinfo{'Script'} = unpack('c', substr($finderinfo_raw, 24, 1));
-    $finderinfo{'XFlags'} = unpack('B8', substr($finderinfo_raw, 25, 1));
-    $finderinfo{'Comment'} = unpack('n', substr($finderinfo_raw, 26, 2));
-    $finderinfo{'PutAway'} = unpack('N', substr($finderinfo_raw, 28, 4));
-
-    my $labelcolor = $this->{'_labelcolors'}->{$finderinfo{'Label'}};
-    my $labelname = $this->{'_labelnames'}->{$finderinfo{'Label'}};
-    $finderinfo{'LabelColor'} = defined($labelcolor)? $labelcolor : '(no labelcolor provided)';
-    $finderinfo{'LabelName'} = defined($labelname)? $labelname : '(no labelname provided)';
-
-    $this->{'_finder_info'} = \%finderinfo;
+	my $this = shift;
+	my $finderinfo_raw = shift;
+	my(%finderinfo);
+	my $finderInfoRawLen = undef;
+	
+	if (!defined($finderinfo_raw) || "" eq $finderinfo_raw) {
+		$this->{'_finder_info'} = \%finderinfo;
+		return;
+	}
+	$finderInfoRawLen = length $finderinfo_raw;
+	
+	# based on page 7-76 of Inside Macintosh: Finder Interface
+	$finderinfo{'Type'} = substr($finderinfo_raw, 0, 4);
+	if ($finderInfoRawLen >= 4) {
+		$finderinfo{'Creator'} = substr($finderinfo_raw, 4, 4);
+	}
+	if ($finderInfoRawLen >= 8) {
+		$finderinfo{'Flags'} = unpack('n', substr($finderinfo_raw, 8, 2));
+	}
+	if ($finderInfoRawLen >= 9) {
+		# Finder Flags
+		$flagbits = unpack('B8', substr($finderinfo_raw, 8, 1)) .unpack('B8', substr($finderinfo_raw, 9, 1)) ;
+		#print "flagbits is $flagbits\n";
+		$finderinfo{'Label'} = unpack('C', pack('B8', '0'x5 . substr($flagbits, 12, 3)));
+		$finderinfo{'Color'} = $finderinfo{'Label'};
+		$finderinfo{'IsOnDesk'} = substr($flagbits, 15, 1);
+		$finderinfo{'IsShared'} = substr($flagbits, 9, 1);
+		$finderinfo{'HasBeenInited'} = substr($flagbits, 7, 1);
+		$finderinfo{'HasCustomIcon'} = substr($flagbits, 5, 1);
+		$finderinfo{'IsStationery'} = substr($flagbits, 4, 1);
+		$finderinfo{'NameLocked'} = substr($flagbits, 3, 1);
+		$finderinfo{'HasBundle'} = substr($flagbits, 2, 1);
+		$finderinfo{'IsInvisible'} = substr($flagbits, 1, 1);
+		$finderinfo{'IsAlias'} = substr($flagbits, 0, 1);
+	}
+	if ($finderInfoRawLen >= 10) {
+		$finderinfo{'Location'} = unpack('nn', substr($finderinfo_raw, 10, 4));
+	}
+	if ($finderInfoRawLen >= 14) {
+		$finderinfo{'Fldr'} = unpack('n', substr($finderinfo_raw, 14, 2));
+	}
+
+	# Extended Finder Info
+	if ($finderInfoRawLen >= 16) {
+		$finderinfo{'IconID'} = unpack('n', substr($finderinfo_raw, 16, 2));
+	}
+	if ($finderInfoRawLen >= 24) {
+		$finderinfo{'Script'} = unpack('c', substr($finderinfo_raw, 24, 1));
+	}
+	if ($finderInfoRawLen >= 25) {
+		$finderinfo{'XFlags'} = unpack('B8', substr($finderinfo_raw, 25, 1));
+	}
+	if ($finderInfoRawLen >= 26) {
+		$finderinfo{'Comment'} = unpack('n', substr($finderinfo_raw, 26, 2));
+	}
+	if ($finderInfoRawLen >= 28) {
+		$finderinfo{'PutAway'} = unpack('N', substr($finderinfo_raw, 28, 4));
+	}
+	
+	my $labelcolor = $this->{'_labelcolors'}->{$finderinfo{'Label'}};
+	my $labelname = $this->{'_labelnames'}->{$finderinfo{'Label'}};
+	$finderinfo{'LabelColor'} = defined($labelcolor)? $labelcolor : '(no labelcolor provided)';
+	$finderinfo{'LabelName'} = defined($labelname)? $labelname : '(no labelname provided)';
+	
+	$this->{'_finder_info'} = \%finderinfo;
 }
 
 sub _get_entry_from_file
