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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]