Commit 4c8b8698 authored by Vasiliy Kulikov's avatar Vasiliy Kulikov Committed by Mauro Carvalho Chehab

[media] rc: ir-lirc-codec: fix potential integer overflow

'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: default avatarVasiliy Kulikov <segoon@openwall.com>
Acked-by: default avatarJarod Wilson <jarod@redhat.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 87d1a50c
...@@ -100,7 +100,8 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, ...@@ -100,7 +100,8 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
struct lirc_codec *lirc; struct lirc_codec *lirc;
struct rc_dev *dev; struct rc_dev *dev;
int *txbuf; /* buffer with values to transmit */ int *txbuf; /* buffer with values to transmit */
int ret = 0, count; int ret = 0;
size_t count;
lirc = lirc_get_pdata(file); lirc = lirc_get_pdata(file);
if (!lirc) if (!lirc)
...@@ -110,7 +111,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf, ...@@ -110,7 +111,7 @@ static ssize_t ir_lirc_transmit_ir(struct file *file, const char *buf,
return -EINVAL; return -EINVAL;
count = n / sizeof(int); count = n / sizeof(int);
if (count > LIRCBUF_SIZE || count % 2 == 0) if (count > LIRCBUF_SIZE || count % 2 == 0 || n % sizeof(int) != 0)
return -EINVAL; return -EINVAL;
txbuf = memdup_user(buf, n); txbuf = memdup_user(buf, n);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment