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

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

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 3, 2012, 20:11 UTC
Message-ID
<7vboqktukz.fsf@alter.siamese.dyndns.org>
In-Reply-To
<CACsJy8B5B2bx7WK7ViziseuWCPaMgcc-avwtsw2DybRme8Vgfg@mail.gmail.com>
Nguyen Thai Ngoc Duy <pclouds@gmail.com> writes:
Show 13 quoted lines
> On Tue, Jan 3, 2012 at 8:13 AM, Brian Harring <ferringb@gmail.com> wrote:
>> @@ -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.
Previous: Nguyen Thai Ngoc DuyNext: Brian Harring
Message 4 of 6 in “fix hang in git fetch if pointed at a 0 length bundle”
  1. fix hang in git fetch if pointed at a 0 length bundleBrian Harring, Jan 3, 2012
  2. Johannes SixtJan 3, 2012
  3. Nguyen Thai Ngoc DuyJan 3, 2012
  4. Junio C HamanoJan 3, 2012
  5. fix hang in git fetch if pointed at a 0 length bundleBrian Harring, Jan 3, 2012
  6. Junio C HamanoJan 3, 2012

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.