From: Johannes Schindelin Date: Mon, 26 Feb 2007 16:47:31 GMT Subject: Re: [PATCH] fetch--tool: fix uninitialized buffer when reading from stdin Message-ID: In-Reply-To: Hi, On Mon, 26 Feb 2007, Linus Torvalds wrote: > > + 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