Thread (1 message) 1 message, 1 author, 2016-06-15

Re: [PATCH] fix hang in git fetch if pointed at a 0 length bundle

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:52:43

Nguyen Thai Ngoc Duy [off-list ref] writes:
On Tue, Jan 3, 2012 at 8:13 AM, Brian Harring [off-list ref] wrote:
quoted
@@ -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')
I think it should return 0 when len == 0 because strictly speaking eof
is not a fault.
Even if you do not strictly speak, end of file is a perfectly normal thing
to see, no?  IOW wouldn't the original patch actively _break_ callers that
read the whole file from the file descriptor to the end?
FWIW I went through all xread call sites. All seem to handle return
value <= 0 correctly.
Thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help