Re: [RFC/WIP PATCH 06/11] remote.h: add get_remote_capabilities, request_capabilities
- From
Jeff King <peff@peff.net>
- Date
- May 27, 2015, 20:09 UTC
- Message-ID
- <20150527200924.GA14309@peff.net>
- In-Reply-To
- <CAPig+cQUtjVbdF5eEo0EH-QXz4q_UqOtoFZ5DcTNzceCxWLS=A@mail.gmail.com>
On Wed, May 27, 2015 at 01:19:39PM -0400, Eric Sunshine wrote:
Show 14 quoted lines
> >> 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. > > Thanks. I had started digging into packet_read() to determine whether > it guaranteed NUL-termination, but didn't get far enough to decide. I > agree that if NUL-termination is guaranteed, then the 'len > 4' check > is superfluous (and confusing, which is why it caught my attention in > the first place).
Yeah, agreed that it should be cleaned up. Interestingly, if you dig on that line, I've touched it several times myself and never noticed this. :)
-Peff