Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Johannes Sixt
Am 20.08.2013 20:52, schrieb Junio C Hamano: Junio C Hamano writes: I wonder if there are more like this broken caller or xread and/or xwrite. Here is a result of a quick audit (of 1.8.0.x codebase). As xwrite() will not be splitting a single-byte request, the patch to cat-file is more or l

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Junio C Hamano
Junio C Hamano writes: > I wonder if there are more like this broken caller or xread and/or > xwrite. Here is a result of a quick audit (of 1.8.0.x codebase). As xwrite() will not be splitting a single-byte request, the patch to cat-file is more or less a theoretical fix, but if writing the dat

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Johannes Sixt
Am 20.08.2013 17:16, schrieb Antoine Pelisse: I was actually wondering when it's better to use xread() over read_in_full() ? Considering that we don't know if xread() will read the whole buffer or not, would it not be better to always use read_in_full() ? Of course, you know whether the whole b

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Junio C Hamano
Antoine Pelisse writes: > I was actually wondering when it's better to use xread() over > read_in_full()? When the caller wants to do more control over a read that may have to loop. For example, this loop in builtin/index-pack.c::fill() do { ssize_t ret = xread(input_fd

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Johannes Sixt
Am 20.08.2013 17:00, schrieb Junio C Hamano: I wonder if there are more like this broken caller or xread and/or xwrite. Looking at the grep -C1 output, there are no others. The only one that looked suspicious was xread in remote-curl.c, but it is fine (it just eats all data from the input).

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Antoine Pelisse
On Tue, Aug 20, 2013 at 5:00 PM, Junio C Hamano wrote: > Johannes Sixt writes: > >> The deflate loop in bulk-checkin::stream_to_pack expects to get all bytes >> from a file that it requests to read in a single function call. But it >> used xread(), which does not give that guarantee. Replace it b

Re: [PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Junio C Hamano
Johannes Sixt writes: > The deflate loop in bulk-checkin::stream_to_pack expects to get all bytes > from a file that it requests to read in a single function call. But it > used xread(), which does not give that guarantee. Replace it by > read_in_full(). > > Signed-off-by: Johannes Sixt > --- >

[PATCH] stream_to_pack: xread does not guarantee to read all requested bytes

2013-08-20 Thread Johannes Sixt
The deflate loop in bulk-checkin::stream_to_pack expects to get all bytes from a file that it requests to read in a single function call. But it used xread(), which does not give that guarantee. Replace it by read_in_full(). Signed-off-by: Johannes Sixt --- The size is limited to sizeof(ibuf) ==