From 5d36c422a7ae6b98ea331bd2d81e936f2feecc04 Mon Sep 17 00:00:00 2001 From: Markham Date: Wed, 31 Oct 2018 23:55:15 +0100 Subject: [PATCH] libdvbsi++: fix-descriptorLenghth thx Satbaby fix_ac3_descriptor fix_network_id --- .../libdvbsi++-fix-descriptorLenghth.patch | 14 +++++++ .../libdvbsi++-fix_ac3_descriptor.patch | 19 +++++++++ .../libdvbsi++-fix_network_id.patch | 40 +++++++++++++++++++ make/libraries.mk | 3 ++ 4 files changed, 76 insertions(+) create mode 100644 archive-patches/libdvbsi++-fix-descriptorLenghth.patch create mode 100644 archive-patches/libdvbsi++-fix_ac3_descriptor.patch create mode 100644 archive-patches/libdvbsi++-fix_network_id.patch diff --git a/archive-patches/libdvbsi++-fix-descriptorLenghth.patch b/archive-patches/libdvbsi++-fix-descriptorLenghth.patch new file mode 100644 index 0000000..2a7202c --- /dev/null +++ b/archive-patches/libdvbsi++-fix-descriptorLenghth.patch @@ -0,0 +1,14 @@ +diff --git a/src/descriptor.cpp b/src/descriptor.cpp +index 8c914a9..beaf4d7 100644 +--- a/src/descriptor.cpp ++++ b/src/descriptor.cpp +@@ -17,6 +17,9 @@ Descriptor::Descriptor(const uint8_t * const buffer) + descriptorTag = buffer[0]; + descriptorLength = buffer[1]; + ++ if (!descriptorLength) ++ descriptorLength = 1; ++ + dataBytes.resize(descriptorLength); + memcpy(&dataBytes[0], &buffer[2], descriptorLength); + diff --git a/archive-patches/libdvbsi++-fix_ac3_descriptor.patch b/archive-patches/libdvbsi++-fix_ac3_descriptor.patch new file mode 100644 index 0000000..d424b28 --- /dev/null +++ b/archive-patches/libdvbsi++-fix_ac3_descriptor.patch @@ -0,0 +1,19 @@ +--- a/src/ac3_descriptor.cpp ++++ b/src/ac3_descriptor.cpp +@@ -31,6 +31,16 @@ Ac3Descriptor::Ac3Descriptor(const uint8_t * const buffer) : Descriptor(buffer) + asvcFlag = (buffer[2] >> 4) & 0x01; + + size_t headerLength = 1 + ac3TypeFlag + bsidFlag + mainidFlag + asvcFlag; ++ ++ // broadcasters got it wrong again... ++ if (headerLength > descriptorLength) { ++ ac3TypeFlag = 0; ++ bsidFlag = 0; ++ mainidFlag = 0; ++ asvcFlag = 0; ++ return; ++ } ++ + ASSERT_MIN_DLEN(headerLength); + + size_t i = 3; diff --git a/archive-patches/libdvbsi++-fix_network_id.patch b/archive-patches/libdvbsi++-fix_network_id.patch new file mode 100644 index 0000000..596a05a --- /dev/null +++ b/archive-patches/libdvbsi++-fix_network_id.patch @@ -0,0 +1,40 @@ +--- a/include/dvbsi++/network_information_section.h ++++ b/include/dvbsi++/network_information_section.h +@@ -37,6 +37,7 @@ typedef TransportStreamInfoList::const_iterator TransportStreamInfoConstIterator + class NetworkInformationSection : public LongCrcSection, public DescriptorContainer + { + protected: ++ unsigned networkId : 16; + unsigned networkDescriptorsLength : 12; + unsigned transportStreamLoopLength : 12; + TransportStreamInfoList tsInfo; +@@ -49,6 +50,7 @@ class NetworkInformationSection : public LongCrcSection, public DescriptorContai + static const enum TableId TID = TID_NIT_ACTUAL; + static const uint32_t TIMEOUT = 12000; + ++ uint16_t getNetworkId(void) const; + const TransportStreamInfoList *getTsInfo(void) const; + }; + +--- a/src/network_information_section.cpp ++++ b/src/network_information_section.cpp +@@ -35,6 +35,7 @@ uint16_t TransportStreamInfo::getOriginalNetworkId(void) const + + NetworkInformationSection::NetworkInformationSection(const uint8_t * const buffer) : LongCrcSection(buffer) + { ++ networkId = UINT16(&buffer[3]); + networkDescriptorsLength = sectionLength > 9 ? DVB_LENGTH(&buffer[8]) : 0; + + uint16_t pos = 10; +@@ -68,6 +69,11 @@ NetworkInformationSection::~NetworkInformationSection(void) + delete *i; + } + ++uint16_t NetworkInformationSection::getNetworkId(void) const ++{ ++ return networkId; ++} ++ + const TransportStreamInfoList *NetworkInformationSection::getTsInfo(void) const + { + return &tsInfo; diff --git a/make/libraries.mk b/make/libraries.mk index 53935e5..757d82b 100755 --- a/make/libraries.mk +++ b/make/libraries.mk @@ -711,6 +711,9 @@ $(D)/libdvbsi++: $(ARCHIVE)/libdvbsi++-$(LIBDVBSI_GIT).tar.bz2 | $(TARGETPREFIX) $(PATCH)/libdvbsi++-src-time_date_section.cpp-fix-sectionLength-check.patch; \ $(PATCH)/libdvbsi++-fix-unaligned-access-on-SuperH.patch; \ $(PATCH)/libdvbsi++-content_identifier_descriptor.patch; \ + $(PATCH)/libdvbsi++-fix_network_id.patch; \ + $(PATCH)/libdvbsi++-fix_ac3_descriptor.patch; \ + $(PATCH)/libdvbsi++-fix-descriptorLenghth.patch; \ $(CONFIGURE) CPPFLAGS=$(DVBSI_CPPFLAG) \ --prefix=$(TARGETPREFIX) \ --build=$(BUILD) \ -- 2.39.5