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: <CAHp75VeJovidU+dWL6Su9YkpP+zmMUw=yrtLh2PmGRZRun-D8g@mail.gmail.com>
Date:	Fri, 11 Dec 2015 19:00:32 +0200
From:	Andy Shevchenko <andy.shevchenko@...il.com>
To:	Kees Cook <keescook@...omium.org>
Cc:	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	Rasmus Villemoes <linux@...musvillemoes.dk>,
	Daniel Borkmann <daniel@...earbox.net>,
	Ingo Molnar <mingo@...hat.com>,
	Andy Lutomirski <luto@...capital.net>,
	"H. Peter Anvin" <hpa@...or.com>,
	Michael Ellerman <mpe@...erman.id.au>,
	Mathias Krause <minipli@...glemail.com>,
	Thomas Gleixner <tglx@...utronix.de>,
	"x86@...nel.org" <x86@...nel.org>, Arnd Bergmann <arnd@...db.de>,
	PaX Team <pageexec@...email.hu>,
	Emese Revfy <re.emese@...il.com>,
	kernel-hardening@...ts.openwall.com,
	linux-arch <linux-arch@...r.kernel.org>
Subject: Re: [PATCH v3 2/8] lib: add "on" and "off" to strtobool

On Wed, Dec 9, 2015 at 11:43 PM, Kees Cook <keescook@...omium.org> wrote:
> Several places in the kernel expect to use "on" and "off" for their
> boolean signifiers, so add them to strtobool.
>
> Signed-off-by: Kees Cook <keescook@...omium.org>
> Cc: Rasmus Villemoes <linux@...musvillemoes.dk>
> Cc: Daniel Borkmann <daniel@...earbox.net>
> ---
>  lib/string.c | 21 ++++++++++++++++++++-
>  1 file changed, 20 insertions(+), 1 deletion(-)
>
> diff --git a/lib/string.c b/lib/string.c
> index 0323c0d5629a..d7550432f91c 100644
> --- a/lib/string.c
> +++ b/lib/string.c
> @@ -635,12 +635,16 @@ EXPORT_SYMBOL(sysfs_streq);
>   * @s: input string
>   * @res: result
>   *
> - * This routine returns 0 iff the first character is one of 'Yy1Nn0'.
> + * This routine returns 0 iff the first character is one of 'Yy1Nn0', or
> + * 'Oo' when the second character is one of 'fFnN' (for "on" and "off").

Maybe

…or [Oo][FfNn] for "off" and "on"…


>   * Otherwise it will return -EINVAL.  Value pointed to by res is
>   * updated upon finding a match.
>   */
>  int strtobool(const char *s, bool *res)
>  {

> +       if (!s)
> +               return -EINVAL;
> +

This change I think is better to do separately. Do we have even need for it?

>         switch (s[0]) {
>         case 'y':
>         case 'Y':
> @@ -652,6 +656,21 @@ int strtobool(const char *s, bool *res)
>         case '0':
>                 *res = false;
>                 break;
> +       case 'o':
> +       case 'O':
> +               switch (s[1]) {
> +               case 'n':
> +               case 'N':
> +                       *res = true;
> +                       break;
> +               case 'f':
> +               case 'F':
> +                       *res = false;
> +                       break;


> +               default:
> +                       return -EINVAL;
> +               }
> +               break;
>         default:
>                 return -EINVAL;

Maybe in both cases
default:
 break;
}
…
}
return -EINVAL;

-- 
With Best Regards,
Andy Shevchenko
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ