Commit 86d5fe68 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dr_58: add boundary checking

parent 709f80dd
...@@ -84,7 +84,12 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr( ...@@ -84,7 +84,12 @@ dvbpsi_local_time_offset_dr_t * dvbpsi_DecodeLocalTimeOffsetDr(
p_current->i_next_time_offset = ((uint16_t)p_data[11] << 8) p_current->i_next_time_offset = ((uint16_t)p_data[11] << 8)
| (uint16_t)p_data[12]; | (uint16_t)p_data[12];
/* NOTE: Only decode upto DVBPSI_LOCAL_TIME_OFFSET_DR_MAX number of time
offsets. The decoding struct cannot hold more then that. */
p_decoded->i_local_time_offsets_number++; p_decoded->i_local_time_offsets_number++;
if (p_decoded->i_local_time_offsets_number == DVBPSI_LOCAL_TIME_OFFSET_DR_MAX)
break;
p_data += 13; p_data += 13;
p_current++; p_current++;
} }
...@@ -101,6 +106,9 @@ dvbpsi_descriptor_t * dvbpsi_GenLocalTimeOffsetDr( ...@@ -101,6 +106,9 @@ dvbpsi_descriptor_t * dvbpsi_GenLocalTimeOffsetDr(
dvbpsi_local_time_offset_dr_t * p_decoded, dvbpsi_local_time_offset_dr_t * p_decoded,
bool b_duplicate) bool b_duplicate)
{ {
if (p_decoded->i_local_time_offsets_number > DVBPSI_LOCAL_TIME_OFFSET_DR_MAX)
p_decoded->i_local_time_offsets_number = DVBPSI_LOCAL_TIME_OFFSET_DR_MAX;
/* Create the descriptor */ /* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor = dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x58, p_decoded->i_local_time_offsets_number * 13, NULL); dvbpsi_NewDescriptor(0x58, p_decoded->i_local_time_offsets_number * 13, NULL);
......
...@@ -65,6 +65,12 @@ typedef struct dvbpsi_local_time_offset_s ...@@ -65,6 +65,12 @@ typedef struct dvbpsi_local_time_offset_s
} dvbpsi_local_time_offset_t; } dvbpsi_local_time_offset_t;
/*!
* \def DVBPSI_LOCAL_TIME_OFFSET_DR_MAX
* \brief Maximum number of dvbpsi_local_time_offset_t entries present in
* @see dvbpsi_local_time_offset_dr_t
*/
#define DVBPSI_LOCAL_TIME_OFFSET_DR_MAX 19
/***************************************************************************** /*****************************************************************************
* dvbpsi_local_time_offset_dr_t * dvbpsi_local_time_offset_dr_t
...@@ -83,11 +89,11 @@ typedef struct dvbpsi_local_time_offset_s ...@@ -83,11 +89,11 @@ typedef struct dvbpsi_local_time_offset_s
typedef struct dvbpsi_local_time_offset_dr_s typedef struct dvbpsi_local_time_offset_dr_s
{ {
uint8_t i_local_time_offsets_number; /*!< local time offset number */ uint8_t i_local_time_offsets_number; /*!< local time offset number */
dvbpsi_local_time_offset_t p_local_time_offset[19]; /*!< local time offset */ dvbpsi_local_time_offset_t
p_local_time_offset[DVBPSI_LOCAL_TIME_OFFSET_DR_MAX]; /*!< local time offset */
} dvbpsi_local_time_offset_dr_t; } dvbpsi_local_time_offset_dr_t;
/***************************************************************************** /*****************************************************************************
* dvbpsi_DecodeLocalTimeOffsetDr * dvbpsi_DecodeLocalTimeOffsetDr
*****************************************************************************/ *****************************************************************************/
......
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