git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix hang in git fetch if pointed at a 0 length bundle
@ 2012-01-03  1:13 Brian Harring
  2012-01-03  8:35 ` Johannes Sixt
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Brian Harring @ 2012-01-03  1:13 UTC (permalink / raw)
  To: git; +Cc: spearce

git-repo if interupted at the exact wrong time will generate zero
length bundles- literal empty files.  git-repo is wrong here, but
git fetch shouldn't effectively spin loop if pointed at a zero
length bundle.

Signed-off-by: Brian Harring <ferringb@chromium.org>
---
 bundle.c          |    2 +-
 t/t5704-bundle.sh |   10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/bundle.c b/bundle.c
index 4742f27..ac9cc20 100644
--- a/bundle.c
+++ b/bundle.c
@@ -31,7 +31,7 @@ static int strbuf_readline_fd(struct strbuf *sb, int fd)
 	while (1) {
 		char ch;
 		ssize_t len = xread(fd, &ch, 1);
-		if (len < 0)
+		if (len <= 0)
 			return -1;
 		strbuf_addch(sb, ch);
 		if (ch == '\n')
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index 728ccd8..75ce5b8 100755
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
@@ -53,4 +53,14 @@ test_expect_failure 'bundle --stdin <rev-list options>' '
 
 '
 
+test_expect_success 'die if bundle file is empty' '
+
+   echo -n > empty-bundle
+   timeout 5 git fetch empty-bundle
+   ret=$?
+   [ $ret == 128 ] && return 0
+   return $ret
+
+'
+
 test_done
-- 
1.7.8.2

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-01-03 20:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-03  1:13 [PATCH] fix hang in git fetch if pointed at a 0 length bundle Brian Harring
2012-01-03  8:35 ` Johannes Sixt
2012-01-03 12:07 ` Nguyen Thai Ngoc Duy
2012-01-03 20:11   ` Junio C Hamano
2012-01-03 13:46 ` Brian Harring
2012-01-03 20:13   ` Junio C Hamano

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 NNTP newsgroup(s).