Re: [PATCH 1/2] dir.c: avoid gcc warning

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

 



On Fri, May 06, 2022 at 01:21:33PM -0700, Junio C Hamano wrote:
> Michael J Gruber <git@xxxxxxxxx> writes:
>
> > Related to -Wstringop-overread.
> >
> > In fact, this may be a false positive, but reading until the correct end
> > is desirable here anyways.
>
> But the correct end is start + (end - start), not start + (end -
> start + 1), isn't it?  We've stripped trailing junk like /.git and
> end is point at one byte beyond the end of URL to the repository.
>
> E.g. for "https://auth@host/";, we have advanced start to point at
> "h" at the beginning of "host", and we have moved end back from
> pointing at the NUL at the end to point at "/" at the end of
> "host/".
>
> We are trying to make sure that the resulting "host" string between
> start and end do not have a slash to apply this special case.
>
> If the original URL were "https://auth@host:4321/";, the end points
> at "/" at the end of "host:4321/", making the string to be checked
> to "host:4321" and we are trying to see it has no '/' in it (which
> is the case).  By extending the string by one, memchr() will see the
> '/' at the end that is outside.
>
> This seems to be a behaviour breaking change and I am not sure what
> we are trying to achieve with it.  Is this a suggestion made by a
> broken compiler you have, or something?

I agree with this reasoning; the change here does not seem correct to
me, and the original version looks to be doing what it advertises.

Thanks,
Taylor



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

  Powered by Linux