[media] dvb: si21xx: buffer overflow in si21_writeregs()
authorDan Carpenter <dan.carpenter@oracle.com>
Tue, 9 Sep 2014 12:05:28 +0000 (09:05 -0300)
committerMauro Carvalho Chehab <mchehab@osg.samsung.com>
Tue, 23 Sep 2014 19:13:38 +0000 (16:13 -0300)
"len" is user controlled and can be up to 255.  Anything more than 59
will cause a buffer overflow so we need to add a test for that.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
drivers/media/dvb-frontends/si21xx.c

index 73b47cc6a13b3b8c2f6ca85d0ee1d9eee71120c1..16850e2bf02fe37bccc4c54af466a43f5dd61b85 100644 (file)
@@ -236,6 +236,9 @@ static int si21_writeregs(struct si21xx_state *state, u8 reg1,
                                .len = len + 1
        };
 
+       if (len > sizeof(buf) - 1)
+               return -EINVAL;
+
        msg.buf[0] =  reg1;
        memcpy(msg.buf + 1, data, len);