Thread (10 messages) 10 messages, 7 authors, 2020-07-01

Re: [PATCH] lib: Extend kstrtobool() to accept "true"/"false"

From: Kees Cook <hidden>
Date: 2020-06-26 15:51:54
Also in: lkml

On Fri, Jun 26, 2020 at 12:44:42PM +0200, Peter Zijlstra wrote:
On Fri, Jun 26, 2020 at 12:22:55PM +0200, Peter Zijlstra wrote:
quoted
quoted
This is too lax - it will be enabled for any !0 value. Please accept
only 0 and 1.
kstrtobool() ftw
And looking at that, I find it really strange it does not in fact accept
"true" / "false", so how about this?

---
Subject: lib: Extend kstrtobool() to accept "true"/"false"

Extend the strings recognised by kstrtobool() to cover:

  - 1/0
  - y/n
  - yes/no	(new)
  - t/f		(new)
  - true/false  (new)
  - on/off

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
There were some worries about dealing with unterminated strings when I
did the original conversion[1], but I think those all got fixed.

Reviewed-by: Kees Cook <redacted>

[1] https://lore.kernel.org/lkml/CAGXu5jJrFv5Y8Q_i3yFYBDmT0+pO05dS3ijB0gOn-huasxZWmA@mail.gmail.com/ (local)

-- 
Kees Cook
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help