Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1327602

RE: [PATCH v2 2/4] lib: update single-char callers of strtobool

From David Laight <David.Laight@ACULAB.COM>
Newsgroups linux.kernel
Subject RE: [PATCH v2 2/4] lib: update single-char callers of strtobool
Date 2016-02-05 12:00 +0100
Message-ID <qYMhk-7w9-3@gated-at.bofh.it> (permalink)
References <qYzk6-7oW-13@gated-at.bofh.it> <qYzk6-7oW-15@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Kees Cook
> Sent: 04 February 2016 21:01
> Some callers of strtobool were passing a pointer to unterminated strings.
> In preparation of adding multi-character processing to kstrtobool, update
> the callers to not pass single-character pointers, and switch to using the
> new kstrtobool_from_user helper where possible.

Personally I think you should change the name of the function so that the
compiler (and linker) will pick up places that have not been changed.
Relying on people to make the required changes will cause problems.

The current code (presumably) treats "no", "nyet" and "nkjkkrkjrkjterkj" as false.
Changing that behaviour will break things.

If you want to support "on" and "off", then maybe check for the supplied string
starting with the character sequences "on\0" and "off\0" (as well as any others).
This doesn't need the input string be '\0' terminated - since you match y and n
without looking at the 2nd byte.
You'd have to be extremely unlucky to get a page fault in the 3 bytes
following an 'o' if the caller supplied a single byte buffer.

	David

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 2/4] lib: update single-char callers of strtobool Kees Cook <keescook@chromium.org> - 2016-02-04 22:10 +0100
  Re: [PATCH v2 2/4] lib: update single-char callers of strtobool Andy Shevchenko <andy.shevchenko@gmail.com> - 2016-02-05 00:00 +0100
    Re: [PATCH v2 2/4] lib: update single-char callers of strtobool Kees Cook <keescook@chromium.org> - 2016-02-05 00:10 +0100
  RE: [PATCH v2 2/4] lib: update single-char callers of strtobool David Laight <David.Laight@ACULAB.COM> - 2016-02-05 12:00 +0100
    Re: [PATCH v2 2/4] lib: update single-char callers of strtobool Kees Cook <keescook@chromium.org> - 2016-02-05 22:20 +0100

csiph-web