descriptors: be sure to not read past the buffer
authorMauro Carvalho Chehab <m.chehab@samsung.com>
Fri, 14 Feb 2014 04:22:25 +0000 (13:22 +0900)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Sat, 15 Feb 2014 18:47:59 +0000 (03:47 +0900)
The loop will read 2 bytes from ptr, to get descriptor type and
length. Be sure that those two bytes are available.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
lib/libdvbv5/descriptors.c

index 46c3be9..92ebc54 100644 (file)
@@ -99,7 +99,8 @@ void dvb_parse_descriptors(struct dvb_v5_fe_parms *parms, const uint8_t *buf,
        const uint8_t *ptr = buf;
        struct dvb_desc *current = NULL;
        struct dvb_desc *last = NULL;
-       while (ptr < buf + section_length) {
+
+       while (ptr + 2 < buf + section_length) {
                unsigned desc_type = ptr[0];
                int desc_len  = ptr[1];
                size_t size;