git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] t: handle EOF in test_copy_bytes()

From
Jeff King <peff@peff.net>
Date
Jul 16, 2017, 10:45 UTC
Message-ID
<20170716104532.zyni62mvzz6rglu6@sigill.intra.peff.net>

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>
---
I was playing with SANITIZE=undefined after René's patches to see how
far we had left to go. I forgot to turn off sha1dc, which causes most
programs to die due to the unaligned loads. That means git-archive in
t5000 generates no output, triggering the bug. :)
 t/test-lib-functions.sh | 1 +
 1 file changed, 1 insertion(+)
diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh
index db622c355..50a9a1d1c 100644
--- a/t/test-lib-functions.sh
+++ b/t/test-lib-functions.sh
@@ -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;
 		}
-- 
2.14.0.rc0.452.gc10560834
Next: Jeff King
Message 1 of 4 in “t: handle EOF in test_copy_bytes()”
  1. t: handle EOF in test_copy_bytes()Jeff King, Jul 16, 2017
  2. Jeff KingJul 16, 2017
  3. René ScharfeJul 16, 2017
  4. Jeff KingJul 16, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.