Re: [PATCH v2 07/21] builtin/receive-pack: convert portions to struct object_id

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

 



On Tue, Mar 28, 2017 at 03:07:12AM -0400, Jeff King wrote:
> It took me a while to find it. This is the switch from "len == 48" to
> "len > 8" when matching "shallow" lines. I think this makes sense.
> 
> > Note that in queue_command we are guaranteed to have a NUL-terminated
> > buffer or at least one byte of overflow that we can safely read, so the
> > linelen check can be elided.  We would die in such a case, but not read
> > invalid memory.
> 
> I think linelen is always just strlen(line). Since the queue_command
> function no longer cares about it, perhaps we can just omit it?

I've just looked at this to put in a fix, and I don't agree.  We are
guaranteed that we'll have overflow, but linelen can point to a newline,
not just a NUL, so it isn't always strlen(line).  This is the case in
queue_commands_from_cert.

We do use this value, in computing the reflen value, so I think it's
better to keep it for now.  I agree that a future refactor could convert
it to be NUL-terminated, but I'd rather not make that change here.
-- 
brian m. carlson / brian with sandals: Houston, Texas, US
+1 832 623 2791 | https://www.crustytoothpaste.net/~bmc | My opinion only
OpenPGP: https://keybase.io/bk2204

Attachment: signature.asc
Description: PGP signature


[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]