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: <CAKdAkRR+kmxBzmhBJ80F4pMTbf_oQWiUh-hXaG2tQMRynmWP3A@mail.gmail.com>
Date:	Tue, 8 Nov 2011 10:41:29 -0800
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	JJ Ding <jj_ding@....com.tw>
Cc:	linux-kernel@...r.kernel.org, linux-input@...r.kernel.org,
	JJ Ding <dgdunix@...il.com>
Subject: Re: [PATCH v2] Input: convert obsolete strict_strtox to kstrtox

On Tue, Nov 8, 2011 at 12:47 AM, JJ Ding <jj_ding@....com.tw> wrote:
> On Tue, 08 Nov 2011 15:47:36 +0800, JJ Ding <jj_ding@....com.tw> wrote:
>> On Mon, 7 Nov 2011 22:28:01 -0800, Dmitry Torokhov <dmitry.torokhov@...il.com> wrote:
>> > On Mon, Nov 07, 2011 at 07:59:30PM -0800, Dmitry Torokhov wrote:
>> > >
>> > > Applied, thanks JJ.
>> > >
>> >
>> > Sorry, I take it back...
>> >
>> > > -       if (strict_strtoul(buf, 10, &value) || value > 1)
>> > > +       if (kstrtouint(buf, 10, &value) || value > 1)
>> > >                 return -EINVAL;
>> >
>> > This mangles error condition from kstrtouint and reporting conditions
>> > beside -EINVAL was the reason for introducing new API IIRC. The proper
>> > conversion should be:
>> >
>> >     err = kstrtouint(buf, 10, &value);
>> >     if (err)
>> >             return err;
>> >
>> >     if (value > 1)
>> >             return -EINVAL;
>> >
>> > Thanks.
>> >
>>
>> Thanks, I get it. I'll fix and resend.
>>
>> jj
>>
>
> Thinking a bit more about your suggestion, and looking at the code more
> closely, some uses of these conversions really want a u8, and some want a
> bool. I think I should check the data type where these converted values
> are really used, and use a more appropriate kstrtox.

If some really want full u8 range then yes, I agree, kstrtou8 is best. For
ones where we have just a few valid values I think we should stick with
conversing to unsigned int and then validate the range manually.

>
> And for those that just need a bool, do you think using strtobool
> introduced in commit d0f1fed29e6e73d9d17f4c91a5896a4ce3938d45 OK?
> That way the user may even type [NnYy01].

I do not like strtobool because it is sloppy. It will also accept 10, yoda, nada
and similar inputs as correct.

Thanks.

-- 
Dmitry
--
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