Merge branch 'master' of code.vuplus.com:/opt/repository/openvuplus_3.0
[vuplus_openvuplus_3.0] / meta-openvuplus / recipes-multimedia / libdvbsi++ / files / 0001-ac3_descriptor-check-if-header-is-larger-than-descri.patch
1 From cb2b7ce505701fd6c10c2700eb1c515f094544e8 Mon Sep 17 00:00:00 2001
2 From: Athanasios Oikonomou <athoik@gmail.com>
3 Date: Sat, 18 Nov 2017 07:57:35 +0200
4 Subject: [PATCH] ac3_descriptor: check if header is larger than descriptor
5
6 It seems another broadcaster got it wrong.
7
8 6A     Tag 0x6A: AC-3_descriptor
9 02     Tag Length: 0x02
10 CF 00
11
12 In above case the descriptor length is 2 and header lenght is 3.
13 The ASSERT_MIN_DLEN fails and ac3 fails to parse.
14 Set sane defaults in this case too.
15
16 diff --git a/src/ac3_descriptor.cpp b/src/ac3_descriptor.cpp
17 index c7b28b2..fec8c31 100644
18 --- a/src/ac3_descriptor.cpp
19 +++ b/src/ac3_descriptor.cpp
20 @@ -31,6 +31,16 @@ Ac3Descriptor::Ac3Descriptor(const uint8_t * const buffer) : Descriptor(buffer)
21         asvcFlag = (buffer[2] >> 4) & 0x01;
22  
23         size_t headerLength = 1 + ac3TypeFlag + bsidFlag + mainidFlag + asvcFlag;
24 +
25 +       // broadcasters got it wrong again...
26 +       if (headerLength > descriptorLength) {
27 +               ac3TypeFlag = 0;
28 +               bsidFlag = 0;
29 +               mainidFlag = 0;
30 +               asvcFlag = 0;
31 +               return;
32 +       }
33 +
34         ASSERT_MIN_DLEN(headerLength);
35  
36         size_t i = 3;
37 -- 
38 2.1.4
39