oggdemux: Protect against invalid granule positions

Only valid values are -1, 0 or positive values. Anything else is
most likely corrupted data streams
This commit is contained in:
Edward Hervey 2017-11-04 11:28:47 +01:00 committed by Edward Hervey
parent c493c564ba
commit 1172e5efc7

View file

@ -662,7 +662,7 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet,
out_offset = 0;
out_offset_end = -1;
} else {
if (packet->granulepos != -1) {
if (packet->granulepos > -1) {
gint64 granule = gst_ogg_stream_granulepos_to_granule (&pad->map,
packet->granulepos);
if (granule < 0) {
@ -1284,6 +1284,15 @@ gst_ogg_pad_stream_out (GstOggPad * pad, gint npackets)
break;
case 1:
GST_LOG_OBJECT (ogg, "packetout gave packet of size %ld", packet.bytes);
if (packet.granulepos < -1) {
GST_WARNING_OBJECT (ogg,
"Invalid granulepos (%" G_GINT64_FORMAT "), resetting stream",
packet.granulepos);
gst_ogg_pad_reset (pad);
break;
}
if (packet.bytes > ogg->max_packet_size)
ogg->max_packet_size = packet.bytes;
result = gst_ogg_pad_submit_packet (pad, &packet);