Commit e9df3130 authored by Jean-Paul Saman's avatar Jean-Paul Saman

dr_55: Add boundary checking.

parent c810f7d7
......@@ -66,6 +66,8 @@ dvbpsi_parental_rating_dr_t * dvbpsi_DecodeParentalRatingDr(
return NULL;
int i_ratings_number = p_descriptor->i_length / 4;
if (i_ratings_number > DVBPSI_PARENTAL_RATING_DR_MAX)
i_ratings_number = DVBPSI_PARENTAL_RATING_DR_MAX;
p_decoded->i_ratings_number = i_ratings_number;
for (int i = 0; i < i_ratings_number; i++)
......@@ -91,6 +93,9 @@ dvbpsi_descriptor_t * dvbpsi_GenParentalRatingDr(
dvbpsi_parental_rating_dr_t * p_decoded,
bool b_duplicate)
{
if (p_decoded->i_ratings_number > DVBPSI_PARENTAL_RATING_DR_MAX)
p_decoded->i_ratings_number = DVBPSI_PARENTAL_RATING_DR_MAX;
/* Create the descriptor */
dvbpsi_descriptor_t * p_descriptor =
dvbpsi_NewDescriptor(0x55, p_decoded->i_ratings_number * 4 , NULL);
......
......@@ -58,6 +58,12 @@ typedef struct dvbpsi_parental_rating_s
} dvbpsi_parental_rating_t;
/*!
* \def DVBPSI_PARENTAL_RATING_DR_MAX
* \brief Maximum number of dvbpsi_parental_rating_t entries present in
* @see dvbpsi_parental_rating_t
*/
#define DVBPSI_PARENTAL_RATING_DR_MAX 64
/*****************************************************************************
* dvbpsi_parental_rating_dr_t
......@@ -76,7 +82,8 @@ typedef struct dvbpsi_parental_rating_s
typedef struct dvbpsi_parental_rating_dr_s
{
uint8_t i_ratings_number; /*!< number of rating */
dvbpsi_parental_rating_t p_parental_rating[64]; /*!< parental rating table */
dvbpsi_parental_rating_t
p_parental_rating[DVBPSI_PARENTAL_RATING_DR_MAX]; /*!< parental rating table */
} dvbpsi_parental_rating_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