From: Aristeu Rozanski <aris@cathedrallabs.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: David Herrmann <dh.herrmann@googlemail.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] uinput strnlen bugfix
Date: Mon, 7 Feb 2011 08:25:18 -0500 [thread overview]
Message-ID: <20110207132518.GJ22170@cathedrallabs.org> (raw)
In-Reply-To: <20110207074017.GA25749@core.coreip.homeip.net>
On Sun, Feb 06, 2011 at 11:40:17PM -0800, Dmitry Torokhov wrote:
> Hmm, not particularly fond with the construct, how about below instead?
>
> Btw, having "Signed-off-by: " from David would be nice.
>
> Thanks.
>
> --
> Dmitry
>
> Input: uinput - fix setting up device name
>
> From: David Herrmann <dh.herrmann@googlemail.com>
>
> The check for non-empty device name was botched since we tried to account
> for extra space for the terminating zero at the same time. Convert to
> kstrndup() to avoid this problem.
>
> Acked-by: Aristeu Rozanski <aris@ruivo.org>
> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
> ---
>
> drivers/input/misc/uinput.c | 13 ++++++-------
> 1 files changed, 6 insertions(+), 7 deletions(-)
>
>
> diff --git a/drivers/input/misc/uinput.c b/drivers/input/misc/uinput.c
> index 82542a1..c0888e3 100644
> --- a/drivers/input/misc/uinput.c
> +++ b/drivers/input/misc/uinput.c
> @@ -347,8 +347,7 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
> {
> struct uinput_user_dev *user_dev;
> struct input_dev *dev;
> - char *name;
> - int i, size;
> + int i;
> int retval;
>
> if (count != sizeof(struct uinput_user_dev))
> @@ -373,19 +372,19 @@ static int uinput_setup_device(struct uinput_device *udev, const char __user *bu
>
> udev->ff_effects_max = user_dev->ff_effects_max;
>
> - size = strnlen(user_dev->name, UINPUT_MAX_NAME_SIZE) + 1;
> - if (!size) {
> + /* Ensure name is filled in */
> + if (!user_dev->name[0]) {
> retval = -EINVAL;
> goto exit;
> }
>
> kfree(dev->name);
> - dev->name = name = kmalloc(size, GFP_KERNEL);
> - if (!name) {
> + dev->name = kstrndup(user_dev->name, UINPUT_MAX_NAME_SIZE,
> + GFP_KERNEL);
> + if (!dev->name) {
> retval = -ENOMEM;
> goto exit;
> }
> - strlcpy(name, user_dev->name, size);
>
> dev->id.bustype = user_dev->id.bustype;
> dev->id.vendor = user_dev->id.vendor;
even better
ACK
--
Aristeu
next prev parent reply other threads:[~2011-02-07 13:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-02-06 16:49 David Herrmann
2011-02-06 16:55 ` Aristeu Rozanski
2011-02-06 16:57 ` David Herrmann
2011-02-06 17:23 ` Aristeu Rozanski
2011-02-07 7:40 ` Dmitry Torokhov
2011-02-07 12:52 ` David Herrmann
2011-02-07 13:25 ` Aristeu Rozanski [this message]
2011-02-08 7:38 ` Dmitry Torokhov
2011-02-08 19:58 ` Aristeu Rozanski
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=20110207132518.GJ22170@cathedrallabs.org \
--to=aris@cathedrallabs.org \
--cc=dh.herrmann@googlemail.com \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/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®