From 0e0aba1f610e7355a9783dfad82dcdacb69ceae4 Mon Sep 17 00:00:00 2001
From: Martin Vallevand <r3o2c7fi@xxxxxxxx>
Date: Thu, 27 Oct 2022 08:45:15 -0400
Subject: [PATCH] libdvbv5: cleanup ASTC service location parsing
Logic attempted to move raw data from the generic DVB descriptor into a
linked list with a different structure. Calculation for the destination
length would always fail as a result. Commit moves specific data elements
---
.../descriptors/desc_atsc_service_location.c | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/lib/libdvbv5/descriptors/desc_atsc_service_location.c
b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
index 8b423dc5..ef88facb 100644
--- a/lib/libdvbv5/descriptors/desc_atsc_service_location.c
+++ b/lib/libdvbv5/descriptors/desc_atsc_service_location.c
@@ -34,21 +34,26 @@ int atsc_desc_service_location_init(struct
dvb_v5_fe_parms *parms,
int i;
size_t len, dlen = desc->length;
- len = sizeof(*s_loc);
+ // raw data should have one element
+ len = sizeof(u_int16_t) + sizeof(u_int8_t) + sizeof(struct
atsc_desc_service_location_elementary);
+
if (dlen < len) {
dvb_logwarn("ATSC service location descriptor is too small");
return -1;
}
- memcpy(s_loc, p, len);
- p += len;
- dlen -= len;
-
+ memcpy(&s_loc->bitfield , p, sizeof(u_int16_t));
+ p += sizeof(u_int16_t);
+ dlen -= sizeof(u_int16_t);
bswap16(s_loc->bitfield);
+ memcpy(&s_loc->number_elements , p, sizeof(u_int8_t));
+ p += sizeof(u_int8_t);
+ dlen -= sizeof(u_int8_t);
+
len = s_loc->number_elements * sizeof(*s_loc->elementary);
if (dlen < len) {
- dvb_logwarn("ATSC service location descriptor is too small");
+ dvb_logwarn("ATSC service location descriptor is too small for
%d elements", s_loc->number_elements);
return -1;
}
if (dlen > len) {
--
2.25.1