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] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200212164627.GU10400@smile.fi.intel.com>
Date:   Wed, 12 Feb 2020 18:46:27 +0200
From:   Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
To:     Alexandru Ardelean <alexandru.ardelean@...log.com>
Cc:     linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
        keescook@...omium.org, tobin@...nel.org, gregkh@...uxfoundation.org
Subject: Re: [PATCH] lib/string: update match_string() doc-strings with
 correct behavior

On Wed, Feb 12, 2020 at 04:47:23PM +0200, Alexandru Ardelean wrote:
> There were a few attempts at changing behavior of the match_string()
> helpers (i.e. 'match_string()' & 'sysfs_match_string()'), to change &
> extend the behavior according to the doc-string.
> 
> But the simplest approach is to just fix the doc-strings. The current
> behavior is fine as-is, and some bugs were introduced trying to fix it.
> 
> As for extending the behavior, new helpers can always be introduced if
> needed.
> 
> The match_string() helpers behave more like 'strncmp()' in the sense that
> they go up to n elements or until the first NULL element in the array of
> strings.
> 
> This change updates the doc-strings with this info.
> 
> Some references to the previous attempts (in no particular order):
>   https://lore.kernel.org/lkml/20190508111913.7276-1-alexandru.ardelean@analog.com/
>   https://lore.kernel.org/lkml/20190625130104.29904-1-alexandru.ardelean@analog.com/
>   https://lore.kernel.org/lkml/20190422083257.21805-1-alexandru.ardelean@analog.com/

...

>  /**
>   * match_string - matches given string in an array
>   * @array:	array of strings
> - * @n:		number of strings in the array or -1 for NULL terminated arrays
> + * @n:		number of strings in the array to compare

But this change won't be helpful, it actually hides the part of behaviour that
is being used.

>   * @string:	string to match with
>   *
> + * This routine will look for a string in an array of strings up to the
> + * n-th element in the array or until the first NULL element.
> + *

Perhaps this needs to be rephrased. Because now it has completely hidden the -1 case.

>   * Return:
>   * index of a @string in the @array if matches, or %-EINVAL otherwise.
>   */

Ditto for the second part.

-- 
With Best Regards,
Andy Shevchenko


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ