h264parser: add more size checks and improve existing

Don't subtract with unsigned values, that will bite us. Also fix format
specifier in the log message.
This commit is contained in:
René Stadler 2011-11-04 13:04:19 +01:00
parent 9f76573bda
commit 9cbc1fd23a

View file

@ -1166,8 +1166,8 @@ gst_h264_parser_identify_nalu (GstH264NalParser * nalparser,
{
gint off1, off2;
if (size - offset < 4) {
GST_DEBUG ("Can't parse, buffer has too small size %" G_GSSIZE_FORMAT
if (size < offset + 4) {
GST_DEBUG ("Can't parse, buffer has too small size %" G_GSIZE_FORMAT
", offset %u", size, offset);
return GST_H264_PARSER_ERROR;
}
@ -1240,6 +1240,12 @@ gst_h264_parser_identify_nalu_avc (GstH264NalParser * nalparser,
{
GstBitReader br;
if (size < offset + nal_length_size) {
GST_DEBUG ("Can't parse, buffer has too small size %" G_GSIZE_FORMAT
", offset %u", size, offset);
return GST_H264_PARSER_ERROR;
}
size = size - offset;
gst_bit_reader_init (&br, data + offset, size);