Re: [PATCH v2 1/2] mailinfo: use starts_with() for clarity

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

 



On Mon, Apr 01, 2019 at 11:53:33PM +0200, Andrei Rybak wrote:

> Existing checks using memcmp(3) never read past the end of the line,
> because all substrings we are interested in are two characters long, and
> the outer loop guarantees we have at least one character. So at most we
> will look at the NUL.
> 
> However, this is too subtle and may lead to bugs in code which copies
> this behavior without realizing substring length requirement.  So use
> starts_with() instead, which will stop at NUL regardless of the length
> of the prefix. Remove extra pair of parentheses while we are here.
> 
> Helped-by: Jeff King <peff@xxxxxxxx>
> Signed-off-by: Andrei Rybak <rybak.a.v@xxxxxxxxx>
> ---
> 
> On Mon, Apr 01, 2019 at 06:11:57 -0400, Jeff King wrote:
> > I wonder if it's worth re-writing it like:
> 
> Turned Peff's suggestion into a patch.

Thanks. I think this may be worth doing regardless of what happens with
patch 2.

-Peff



[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