public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Return EINVAL if read size is not multiple of struct size
@ 2004-11-08 21:29 James Lamanna
  0 siblings, 0 replies; only message in thread
From: James Lamanna @ 2004-11-08 21:29 UTC (permalink / raw)
  To: linux-kernel

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-11-08 21:34 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-08 21:29 [PATCH] Return EINVAL if read size is not multiple of struct size James Lamanna

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox