OSDN Git Service

t: handle EOF in test_copy_bytes()
authorJeff King <peff@peff.net>
Sun, 16 Jul 2017 10:45:32 +0000 (06:45 -0400)
committerJunio C Hamano <gitster@pobox.com>
Mon, 17 Jul 2017 21:55:43 +0000 (14:55 -0700)
The test_copy_bytes() function claims to read up to N bytes,
or until it gets EOF. But we never handle EOF in our loop,
and a short input will cause perl to go into an infinite
loop of read() getting zero bytes.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/test-lib-functions.sh

index db622c3..50a9a1d 100644 (file)
@@ -999,6 +999,7 @@ test_copy_bytes () {
                        my $s;
                        my $nread = sysread(STDIN, $s, $len);
                        die "cannot read: $!" unless defined($nread);
+                       last unless $nread;
                        print $s;
                        $len -= $nread;
                }