From: Martin Koegler Date: Sun, 06 Jan 2008 17:23:22 GMT Subject: Re: [PATCH] tree-walk: don't parse incorrect entries Message-ID: <20080106172322.GA27967@auto.tuwien.ac.at> In-Reply-To: <7v1w8w80a3.fsf@gitster.siamese.dyndns.org> On Sat, Jan 05, 2008 at 12:50:28PM -0800, Junio C Hamano wrote: > Martin Koegler writes: > > * The start of the path may not be after the last zero (21 bytes before the end). > > How can that be possible? > > - you know end points at NUL and buf < end; > > - get_mode() starts scanning from buf, stops at the first SP if > returns a non NULL pointer; anything non octal digit before > it sees that SP results in a NULL return; > > - the return value of get_mode() is the beginning of the path. > > The second point above means when get_mode() scans buf, it would > never go beyond end which you already made sure is NUL (which is > not SP and not an octal digit). If it hits end, you would get NULL > pointer back, wouldn't you? Yes, I agree with you. > Rejecting an empty path may be sensible (i.e. checking "!*path" > instead), though. I sent a new patch with both changes. mfg Martin Kögler