lkml.org 
[lkml]   [2017]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH 05/10] gpio: mockup: improve the debugfs input sanitization
On Sat, May 27, 2017 at 7:45 PM, Andy Shevchenko
<andy.shevchenko@gmail.com> wrote:
> On Thu, May 25, 2017 at 11:33 AM, Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>> We're currently only checking the first character of the input to the
>> debugfs event files, so a string like '0sdfdsf' is valid and indicates
>> a falling edge event.
>>
>> Be more strict and only allow '0', '1', '0\n' & '1\n'.
>
> Why not to be so strict and use
>
> kstrtobool_from_user();
>
> instead?

Or if you still wish to be strict,
ret = kstrtou8_from_user();
if (ret)
return ret;

if (val > 1)
return -ERANGE;

or alike.

--
With Best Regards,
Andy Shevchenko

\
 
 \ /
  Last update: 2017-05-27 18:48    [W:0.085 / U:0.584 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site