summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f3f778d)
raw | patch | inline | side by side (parent: f3f778d)
author | Brian Harring <ferringb@gmail.com> | |
Tue, 3 Jan 2012 13:46:03 +0000 (05:46 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Tue, 3 Jan 2012 20:13:28 +0000 (12:13 -0800) |
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>
Helped-by: Johannes Sixt
Helped-by: Nguyen Thai Ngoc Duy
Signed-off-by: Junio C Hamano <gitster@pobox.com>
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>
Helped-by: Johannes Sixt
Helped-by: Nguyen Thai Ngoc Duy
Signed-off-by: Junio C Hamano <gitster@pobox.com>
bundle.c | patch | blob | history | |
t/t5704-bundle.sh | patch | blob | history |
diff --git a/bundle.c b/bundle.c
index 08020bc3a258e055a8f5f6974217cf482edc3ee3..8a1d53ba29a434139123bd7d4e37db47ba8728cb 100644 (file)
--- a/bundle.c
+++ b/bundle.c
while (1) {
char ch;
ssize_t len = xread(fd, &ch, 1);
- if (len < 0)
- return -1;
+ if (len <= 0)
+ return len;
strbuf_addch(sb, ch);
if (ch == '\n')
break;
diff --git a/t/t5704-bundle.sh b/t/t5704-bundle.sh
index 728ccd88c3d69f06bff2c3593ddc325f9186402c..4ae127d106c4a8ada0cea928affeff933bf0dbaa 100755 (executable)
--- a/t/t5704-bundle.sh
+++ b/t/t5704-bundle.sh
'
+test_expect_success 'empty bundle file is rejected' '
+
+ >empty-bundle && test_must_fail git fetch empty-bundle
+
+'
+
test_done