All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] media: rc: ir-lirc-codec: fix potential integer overflow
@ 2010-11-26 17:06 ` Vasiliy Kulikov
  0 siblings, 0 replies; 16+ messages in thread
From: Vasiliy Kulikov @ 2010-11-26 17:06 UTC (permalink / raw)
  To: kernel-janitors
  Cc: Mauro Carvalho Chehab, David Härdeman, Jarod Wilson,
	linux-media, linux-kernel

'n' may be bigger than MAX_INT*sizeof(int), if so checking of truncated
(int)(n/sizeof(int)) for LIRCBUF_SIZE overflow and then using nontruncated 'count'
doesn't make sense.  Also n may be up to sizeof(int)-1 bytes bigger than expected,
so check value of (n % sizeof(int)) too.

Signed-off-by: Vasiliy Kulikov <segoon@openwall.com>
---
 Compile tested only.

 drivers/media/rc/ir-lirc-codec.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c
index 1e87ee8..f011c5d 100644
--- a/drivers/media/rc/ir-lirc-codec.c
+++ b/drivers/media/rc/ir-lirc-codec.c
@@ -100,7 +100,8 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
 	struct lirc_codec *lirc;
 	struct rc_dev *dev;
 	int *txbuf; /* buffer with values to transmit */
-	int ret = 0, count;
+	int ret = 0;
+	size_t count;
 
 	lirc = lirc_get_pdata(file);
 	if (!lirc)
@@ -110,7 +111,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
 		return -EINVAL;
 
 	count = n / sizeof(int);
-	if (count > LIRCBUF_SIZE || count % 2 = 0)
+	if (count > LIRCBUF_SIZE || count % 2 = 0 || n % sizeof(int) != 0)
 		return -EINVAL;
 
 	txbuf = memdup_user(buf, n);
-- 
1.7.0.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2010-12-08 16:16 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-26 17:06 [PATCH] media: rc: ir-lirc-codec: fix potential integer overflow Vasiliy Kulikov
2010-11-26 17:06 ` Vasiliy Kulikov
2010-12-02  2:47 ` Jarod Wilson
2010-12-02  2:47   ` Jarod Wilson
2010-12-02  4:51 ` [PATCH] media: rc: ir-lirc-codec: fix potential integer Dan Carpenter
2010-12-02  4:51   ` [PATCH] media: rc: ir-lirc-codec: fix potential integer overflow Dan Carpenter
2010-12-02 15:00   ` Jarod Wilson
2010-12-02 15:00     ` Jarod Wilson
2010-12-02 18:55     ` Jarod Wilson
2010-12-02 18:55       ` Jarod Wilson
2010-12-04 21:05   ` [PATCH v2] media: rc: ir-lirc-codec: fix " Vasiliy Kulikov
2010-12-04 21:05     ` Vasiliy Kulikov
2010-12-08 16:15     ` Jarod Wilson
2010-12-08 16:15       ` Jarod Wilson
2010-12-02 21:08 ` [PATCH] media: rc: ir-lirc-codec: fix potential integer Andy Walls
2010-12-02 21:08   ` [PATCH] media: rc: ir-lirc-codec: fix potential integer overflow Andy Walls

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.