From 6c5210a94f8b0ac89a1e97080a4e5d207468da8a Mon Sep 17 00:00:00 2001 From: Johannes Schauer Marin Rodrigues Date: Thu, 22 Dec 2022 10:17:40 +0100 Subject: [PATCH] error out early if setup fails and thus the ext2 block reader returns EOF --- mmdebstrap | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mmdebstrap b/mmdebstrap index 0f88582..f7f393b 100755 --- a/mmdebstrap +++ b/mmdebstrap @@ -5920,7 +5920,13 @@ sub main() { my $numblocks = 0; close $nblkwriter; if (!$options->{dryrun} && $format eq 'ext2') { - chomp($numblocks = <$nblkreader>); + $numblocks = <$nblkreader>; + if (!defined $numblocks) { + # This can happen if the setup process died early and thus closes + # the pipe from the other and. The EOF is turned into undef. + error "failed to read required number of blocks"; + } + chomp $numblocks; } close $nblkreader;