lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Sat, 05 Dec 2020 20:08:53 +0100
From:   Francis Laniel <laniel_francis@...vacyrequired.com>
To:     James Bottomley <James.Bottomley@...senpartnership.com>
Cc:     Ard Biesheuvel <ardb@...nel.org>,
        linux-efi <linux-efi@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [RFC PATCH v1 07/12] efi: Replace strstarts() by str_has_prefix().

Le vendredi 4 décembre 2020, 19:02:09 CET James Bottomley a écrit :
> On Fri, 2020-12-04 at 18:07 +0100, Ard Biesheuvel wrote:
> > On Fri, 4 Dec 2020 at 18:06, <laniel_francis@...vacyrequired.com>
> > 
> > wrote:
> > > From: Francis Laniel <laniel_francis@...vacyrequired.com>
> > > 
> > > The two functions indicates if a string begins with a given prefix.
> > > The only difference is that strstarts() returns a bool while
> > > str_has_prefix()
> > > returns the length of the prefix if the string begins with it or 0
> > > otherwise.
> > 
> > Why?
> 
> I think I can answer that.  If the conversion were done properly (which
> it's not) you could get rid of the double strings in the code which are
> error prone if you update one and forget another.  This gives a good
> example: 3d739c1f6156 ("tracing: Use the return of str_has_prefix() to
> remove open coded numbers"). so in your code you'd replace things like
> 
>     if (strstarts(option, "rgb")) {
>         option += strlen("rgb");
>         ...
> 
> with
> 
>     len = str_has_prefix(option, "rgb");
>     if (len) {
>         option += len
>         ...

The proposed changes were a bit mechanical and I did not think about using the 
returned value in the way you proposed.
This a good idea though, so I can modify my patches to include this and send a 
v2!
 
> Obviously you also have cases where strstart is used as a boolean with
> no need to know the length ... I think there's no value to converting
> those.

For the v2, should I only change cases where using str_has_prefix() brings a 
benefit over strstarts() or all the cases?

> James


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ