From 51c59323fffbfbb6ebc60f58da905e88ac323da5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 25 Apr 2016 09:50:00 +0000 Subject: import: extra check for final byte read The read could fail entirely and leave $lf undefined. --- lib/PublicInbox/Import.pm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Import.pm b/lib/PublicInbox/Import.pm index 7073c3d9..8a40fb53 100644 --- a/lib/PublicInbox/Import.pm +++ b/lib/PublicInbox/Import.pm @@ -93,14 +93,16 @@ sub remove { my $left = $1; my $offset = 0; my $buf = ''; + my $n; while ($left > 0) { - my $n = read($r, $buf, $left, $offset); + $n = read($r, $buf, $left, $offset); defined($n) or die "read cat-blob failed: $!"; $n == 0 and die 'fast-export (cat-blob) died'; $left -= $n; $offset += $n; } - read($r, my $lf, 1); + $n = read($r, my $lf, 1); + defined($n) or die "read final byte of cat-blob failed: $!"; die "bad read on final byte: <$lf>" if $lf ne "\n"; my $cur = Email::MIME->new($buf); if ($cur->header('Subject') ne $mime->header('Subject') || -- cgit v1.2.3-24-ge0c7