Re: [RFC/WIP PATCH 06/11] remote.h: add get_remote_capabilities, request_capabilities
- From
Jeff King <peff@peff.net>
- Date
- May 27, 2015, 06:50 UTC
- Message-ID
- <20150527065030.GE885@peff.net>
- In-Reply-To
- <CAPig+cRfJKAQ8Q5PF1VfTAGA1njXAshC0RbnMv9cEp4bH_MN7A@mail.gmail.com>
On Tue, May 26, 2015 at 11:25:05PM -0400, Eric Sunshine wrote:
Show 14 quoted lines
> > + len = packet_read(in, &src_buf, &src_len, > > + packet_buffer, sizeof(packet_buffer), > > + PACKET_READ_GENTLE_ON_EOF | > > + PACKET_READ_CHOMP_NEWLINE); > > + if (len < 0) > > + die_initial_contact(0); > > + > > + if (!len) > > + break; > > + > > + if (len > 4 && skip_prefix(line, "ERR ", &arg)) > > The 'len > 4' check is needed because there's no guarantee that 'line' > is NUL-terminated. Correct?
I think this was just blindly copied from get_remote_heads(). And I think that code was being overly paranoid. Ever since f3a3214 (Make send/receive-pack be closer to doing something interesting, 2005-06-29), the pkt-line reader will add an extra NUL to the buffer to ease cases like this.
-Peff