Commit 709f80dd authored by Jean-Paul Saman's avatar Jean-Paul Saman

dr_59: Add boundary checking.

parent b9755cd0
......@@ -72,7 +72,8 @@ dvbpsi_subtitling_dr_t * dvbpsi_DecodeSubtitlingDr(
return NULL;
i_subtitles_number = p_descriptor->i_length / 8;
if (i_subtitles_number > DVBPSI_SUBTITLING_DR_MAX)
i_subtitles_number = DVBPSI_SUBTITLING_DR_MAX;
p_decoded->i_subtitles_number = i_subtitles_number;
for (int i = 0; i < i_subtitles_number; i++)
......@@ -105,6 +106,9 @@ dvbpsi_descriptor_t * dvbpsi_GenSubtitlingDr(
dvbpsi_subtitling_dr_t * p_decoded,
bool b_duplicate)
{
if (p_decoded->i_subtitles_number > DVBPSI_SUBTITLING_DR_MAX)
p_decoded->i_subtitles_number = DVBPSI_SUBTITLING_DR_MAX;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x59, p_decoded->i_subtitles_number * 8 , NULL);
......
......@@ -61,6 +61,12 @@ typedef struct dvbpsi_subtitle_s
} dvbpsi_subtitle_t;
/*!
* \def DVBPSI_SUBTITLING_DR_MAX
* \brief Maximum number of dvbpsi_subtitle_t entries present in
* @see dvbpsi_subtitling_dr_t
*/
#define DVBPSI_SUBTITLING_DR_MAX 20
/*****************************************************************************
* dvbpsi_subtitling_dr_t
......@@ -79,7 +85,7 @@ typedef struct dvbpsi_subtitle_s
typedef struct dvbpsi_subtitling_dr_s
{
uint8_t i_subtitles_number; /*!< subtiles number */
dvbpsi_subtitle_t p_subtitle[20]; /*!< subtitles */
dvbpsi_subtitle_t p_subtitle[DVBPSI_SUBTITLING_DR_MAX]; /*!< subtitles */
} dvbpsi_subtitling_dr_t;
......
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