Commit 8c9c3f19 authored by Jean-Paul Saman's avatar Jean-Paul Saman

NIT: cleanup and extra check

parent 177324ad
...@@ -455,13 +455,13 @@ void dvbpsi_nit_sections_gather(dvbpsi_t *p_dvbpsi, ...@@ -455,13 +455,13 @@ void dvbpsi_nit_sections_gather(dvbpsi_t *p_dvbpsi,
void dvbpsi_nit_sections_decode(dvbpsi_nit_t* p_nit, void dvbpsi_nit_sections_decode(dvbpsi_nit_t* p_nit,
dvbpsi_psi_section_t* p_section) dvbpsi_psi_section_t* p_section)
{ {
uint8_t* p_byte, * p_end, * p_end2; uint8_t* p_byte, * p_end;
while (p_section) while (p_section)
{ {
/* - NIT descriptors */ /* - NIT descriptors */
p_byte = p_section->p_payload_start + 2; p_byte = p_section->p_payload_start + 2;
p_end = p_byte + ( ((uint16_t)(p_section->p_payload_start[0] & 0x0f) << 8) p_end = p_byte + (((uint16_t)(p_section->p_payload_start[0] & 0x0f) << 8)
| p_section->p_payload_start[1]); | p_section->p_payload_start[1]);
while (p_byte + 2 <= p_end) while (p_byte + 2 <= p_end)
...@@ -473,28 +473,33 @@ void dvbpsi_nit_sections_decode(dvbpsi_nit_t* p_nit, ...@@ -473,28 +473,33 @@ void dvbpsi_nit_sections_decode(dvbpsi_nit_t* p_nit,
p_byte += 2 + i_length; p_byte += 2 + i_length;
} }
p_end = p_byte + ( ((uint16_t)(p_byte[0] & 0x0f) << 8) /* Transport stream loop length */
p_end = p_byte + (((uint16_t)(p_byte[0] & 0x0f) << 8)
| p_byte[1]); | p_byte[1]);
if (p_end > p_section->p_payload_end) if (p_end > p_section->p_payload_end)
{
p_end = p_section->p_payload_end; p_end = p_section->p_payload_end;
}
p_byte += 2; p_byte += 2;
/* - TSs */ /* - TSs */
for (; p_byte + 6 <= p_end;) while(p_byte + 6 <= p_end)
{ {
uint8_t *p_end2; /* descriptor loop end */
uint16_t i_ts_id = ((uint16_t)p_byte[0] << 8) | p_byte[1]; uint16_t i_ts_id = ((uint16_t)p_byte[0] << 8) | p_byte[1];
uint16_t i_orig_network_id = ((uint16_t)p_byte[2] << 8) | p_byte[3]; uint16_t i_orig_network_id = ((uint16_t)p_byte[2] << 8) | p_byte[3];
uint16_t i_ts_length = ((uint16_t)(p_byte[4] & 0x0f) << 8) | p_byte[5]; uint16_t i_ts_length = ((uint16_t)(p_byte[4] & 0x0f) << 8) | p_byte[5];
dvbpsi_nit_ts_t* p_ts = dvbpsi_nit_ts_add(p_nit, i_ts_id, i_orig_network_id); dvbpsi_nit_ts_t* p_ts = dvbpsi_nit_ts_add(p_nit, i_ts_id, i_orig_network_id);
if (!p_ts)
break;
/* - TS descriptors */ /* - TS descriptors */
p_byte += 6; p_byte += 6;
p_end2 = p_byte + i_ts_length; p_end2 = p_byte + i_ts_length;
if ( p_end2 > p_section->p_payload_end ) if (p_end2 > p_section->p_payload_end)
{
p_end2 = p_section->p_payload_end; p_end2 = p_section->p_payload_end;
}
while (p_byte + 2 <= p_end2) while (p_byte + 2 <= p_end2)
{ {
uint8_t i_tag = p_byte[0]; uint8_t i_tag = p_byte[0];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment