user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 1/3] import: extra check for final byte read
  @ 2016-04-25  9:52  7% ` Eric Wong
  0 siblings, 0 replies; 1+ results
From: Eric Wong @ 2016-04-25  9:52 UTC (permalink / raw)
  To: meta

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 7073c3d..8a40fb5 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') ||
-- 
EW


^ permalink raw reply related	[relevance 7%]

Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2016-04-25  9:52     [PATCH 0/3] remove ssoma dependency from public-inbox Eric Wong
2016-04-25  9:52  7% ` [PATCH 1/3] import: extra check for final byte read Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).