From: James Lamanna <jamesl@appliedminds.com>
To: linux-kernel@vger.kernel.org
Subject: [PATCH] Return EINVAL if read size is not multiple of struct size
Date: Mon, 08 Nov 2004 13:29:26 -0800 [thread overview]
Message-ID: <418FE536.80009@appliedminds.com> (raw)
The following is a small patch to return EINVAL when the value given
to read() from an event device is not a multiple of
sizeof(struct input_event).
Prior to this patch read() with a size less than sizeof(struct input_event)
would always return 0.
This should probably be marked as an error.
Signed-off by: James Lamanna
--- linux-2.6.9/drivers/input/evdev.c 2004-10-18 14:54:40.000000000 -0700
+++ linux-2.6.9-ev-patch/drivers/input/evdev.c 2004-11-08 12:23:45.495800064 -0800
@@ -183,6 +183,9 @@
if (!list->evdev->exist)
return -ENODEV;
+ if (count % sizeof(struct input_event) != 0)
+ return -EINVAL;
+
while (list->head != list->tail && retval + sizeof(struct input_event) <= count) {
if (copy_to_user(buffer + retval, list->buffer + list->tail,
sizeof(struct input_event))) return -EFAULT;
--
James Lamanna
reply other threads:[~2004-11-08 21:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=418FE536.80009@appliedminds.com \
--to=jamesl@appliedminds.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