mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Pavel Machek <pavel@suse.cz>
Cc: rpurdie@rpsys.net, linux-kernel@vger.kernel.org
Subject: Re: backlight: catch invalid input
Date: Fri, 21 Nov 2008 15:54:21 -0800	[thread overview]
Message-ID: <20081121155421.152cc555.akpm@linux-foundation.org> (raw)
In-Reply-To: <20081121111414.GA1455@elf.ucw.cz>

On Fri, 21 Nov 2008 12:14:14 +0100
Pavel Machek <pavel@suse.cz> wrote:

> 
> Currently, echo > brightness turns brightness to zero due to
> insufficient checking. Add a test to catch that.
> 

OK.  And what happens if you do

	echo wibble > brightness

?

> 
> diff --git a/drivers/video/backlight/backlight.c b/drivers/video/backlight/backlight.c
> index fab0bc8..5c2e23d 100644
> --- a/drivers/video/backlight/backlight.c
> +++ b/drivers/video/backlight/backlight.c
> @@ -86,6 +86,8 @@ static ssize_t backlight_store_power(str
>  	int power = simple_strtoul(buf, &endp, 0);
>  	size_t size = endp - buf;
>  
> +	if (!size)
> +		return -EINVAL;
>  	if (*endp && isspace(*endp))
>  		size++;
>  	if (size != count)

A better fix would be to use strict_strtoul() and check its return value.

  reply	other threads:[~2008-11-21 23:55 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-21 11:14 Pavel Machek
2008-11-21 23:54 ` Andrew Morton [this message]
2008-11-22 10:37   ` Pavel Machek
2008-11-22 20:31   ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20081121155421.152cc555.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pavel@suse.cz \
    --cc=rpurdie@rpsys.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®