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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Tue, 10 Aug 2021 17:43:03 +0200
From:   Len Baker <len.baker@....com>
To:     Andy Shevchenko <andy.shevchenko@...il.com>,
        David Laight <David.Laight@...LAB.COM>,
        Jonathan Cameron <Jonathan.Cameron@...wei.com>
Cc:     Len Baker <len.baker@....com>,
        Lars-Peter Clausen <lars@...afoo.de>,
        Kees Cook <keescook@...omium.org>,
        linux-hardening@...r.kernel.org,
        linux-iio <linux-iio@...r.kernel.org>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH v2] drivers/iio: Remove all strcpy() uses in favor of
 strscpy()

Hi Andy, David and Jonathan

First of all thanks you very much for your code snippets ;)
More below.

On Tue, Aug 10, 2021 at 03:11:01PM +0300, Andy Shevchenko wrote:
> On Tue, Aug 10, 2021 at 3:06 PM Andy Shevchenko
> <andy.shevchenko@...il.com> wrote:
> > On Mon, Aug 9, 2021 at 7:14 PM Len Baker <len.baker@....com> wrote:
>
>
>
> > Even if we leave the logic as is, this might be better
> >
> > if (orient[0] == '-')
> >    str = devm_kstrdup(dev, orient + 1, GFP_KERNEL);
>
> > else if (orient[0] != '0' || orient[1] != '\0')
> >    str = devm_kasprintf(dev, GFP_KERNEL, "-%s", orient);
> > else
> >    str = devm_kstrdup(dev, orient, GFP_KERNEL);

I think the above snippet is the right one: Is compact and easy
to understand.

>
> Or these two swapped for better reading
>
>  else if (orient[0] == '0' **&& orient[1] == '\0')
>     str = devm_kstrdup(dev, orient, GFP_KERNEL);
> else
>     str = devm_kasprintf(dev, GFP_KERNEL, "-%s", orient);
>
> And with a comment added that we negate the result according to the
> rules: 1) drop leading '-' (minus); 2) leave 0 as is; add leading '-'
> (minus).
>
> > if (!str)
> >    return -ENOMEM;

Also, I think that it is better to leave the logic as is and don't
try to use always the +/- sign.

Again thanks to all for the feedback.

Regards,
Len

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ