From: Eric Wong Date: Mon, 25 Apr 2016 09:50:00 +0000 (+0000) Subject: import: extra check for final byte read X-Git-Tag: v1.0.0~588 X-Git-Url: http://www.git.stargrave.org/?p=public-inbox.git;a=commitdiff_plain;h=51c59323fffbfbb6ebc60f58da905e88ac323da5 import: extra check for final byte read The read could fail entirely and leave $lf undefined. --- 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') ||