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

Re: [PATCH] fetch--tool: fix uninitialized buffer when reading from stdin

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Feb 26, 2007, 16:47 UTC
Message-ID
<Pine.LNX.4.63.0702261741360.22628@wbgn013.biozentrum.uni-wuerzburg.de>
In-Reply-To
<Pine.LNX.4.64.0702260821310.12485@woody.linux-foundation.org>
Hi,
On Mon, 26 Feb 2007, Linus Torvalds wrote:
Show 6 quoted lines
> > +	if (read > 0 && data[read - 1] == '\n')
> > +		data[read - 1] = '\0';
> > +	else
> > +		data[read] = '\0';
> 
> First off, "read" here may be -1.

Ah yes. I somehow had the erroneous impression that xread() die()s on error like xmalloc()...

> 	/* Why do this? Because Dscho did.. */
> 	if (offset && data[offset-1] == '\n')
> 		offset--;

Well yes, it probably does not change anything except the output, which you see only when debugging.

It's not like I care deeply, because this part of the code will hopefully soon go away, when git-fetch is a proper builtin.

However, I compile with -DXMALLOC_POISON=1 and _that_ did not play well, whereas the read fails rather rarely on stdin...

But I agree your patch is saner.

Ciao, Dscho

Previous: Linus TorvaldsNext: Linus Torvalds
Message 3 of 10 in “fetch--tool: fix uninitialized buffer when reading from stdin”
  1. fetch--tool: fix uninitialized buffer when reading from stdinJohannes Schindelin, Feb 26, 2007
  2. Linus TorvaldsFeb 26, 2007
  3. Johannes SchindelinFeb 26, 2007
  4. Linus TorvaldsFeb 26, 2007
  5. Johannes SchindelinFeb 26, 2007
  6. Johannes SchindelinFeb 26, 2007
  7. Linus TorvaldsFeb 26, 2007
  8. Junio C HamanoFeb 26, 2007
  9. Junio C HamanoFeb 26, 2007
  10. Johannes SchindelinFeb 27, 2007

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.