h265parser: Do not allocate too large size of memory for registered user data SEI

Don't be confused by the unit of payload size (i.e., bits and bytes)
Also this need a documentation with Since mark
This commit is contained in:
Seungha Yang 2020-03-21 18:25:25 +09:00 committed by GStreamer Merge Bot
parent 9e429fad3e
commit ef14a032c1
2 changed files with 24 additions and 8 deletions

View file

@ -1201,8 +1201,10 @@ gst_h265_parser_parse_registered_user_data (GstH265Parser * parser,
rud->data = NULL;
rud->size = 0;
if (payload_size < 2)
return GST_H265_PARSER_ERROR;
if (payload_size < 2) {
GST_WARNING ("Too small payload size %d", payload_size);
return GST_H265_PARSER_BROKEN_DATA;
}
READ_UINT8 (nr, rud->country_code, 8);
--payload_size;
@ -1214,15 +1216,17 @@ gst_h265_parser_parse_registered_user_data (GstH265Parser * parser,
rud->country_code_extension = 0;
}
if (payload_size < 8)
return GST_H265_PARSER_ERROR;
if (payload_size < 1) {
GST_WARNING ("No more remaining payload data to store");
return GST_H265_PARSER_BROKEN_DATA;
}
data = g_malloc (payload_size);
for (i = 0; i < payload_size / 8; ++i) {
for (i = 0; i < payload_size; ++i) {
READ_UINT8 (nr, data[i], 8);
}
GST_MEMDUMP ("SEI user data", data, payload_size / 8);
GST_MEMDUMP ("SEI user data", data, payload_size);
rud->data = data;
rud->size = payload_size;
@ -2574,7 +2578,7 @@ gst_h265_parser_parse_sei_message (GstH265Parser * parser,
payload_start_pos_bit = nal_reader_get_pos (nr);
GST_DEBUG
("SEI message received: payloadType %u, payloadSize = %u bytes",
("SEI message received: payloadType %u, payloadSize = %u bits",
sei->payloadType, payload_size);
if (nal_type == GST_H265_NAL_PREFIX_SEI) {
@ -2591,7 +2595,7 @@ gst_h265_parser_parse_sei_message (GstH265Parser * parser,
break;
case GST_H265_SEI_REGISTERED_USER_DATA:
res = gst_h265_parser_parse_registered_user_data (parser,
&sei->payload.registered_user_data, nr, payloadSize);
&sei->payload.registered_user_data, nr, payload_size >> 3);
break;
case GST_H265_SEI_RECOVERY_POINT:
res = gst_h265_parser_parse_recovery_point (parser,

View file

@ -1406,6 +1406,18 @@ struct _GstH265RecoveryPoint
guint8 broken_link_flag;
};
/**
* GstH265RegisteredUserData:
* The User data registered by Rec. ITU-T T.35 SEI messag.
* @country_code: an itu_t_t35_country_code.
* @country_code_extension: an itu_t_t35_country_code_extension_byte.
* Should be ignored when @country_code is not 0xff
* @data: the data of itu_t_t35_payload_byte
* excluding @country_code and @country_code_extension
* @size: the size of @data in bytes
*
* Since: 1.18
*/
struct _GstH265RegisteredUserData
{
guint8 country_code;