diff options
author | Tim-Philipp Müller <tim@centricular.com> | 2018-02-14 00:22:38 +0000 |
---|---|---|
committer | Tim-Philipp Müller <tim@centricular.com> | 2018-02-14 00:22:38 +0000 |
commit | 466b868459b498edaffd2bdcac998792e6488327 (patch) | |
tree | 8b18775b835e34ac92fc9187503194a475a31466 | |
parent | 54655196e73f3e58430f43a2714e0a4d09a5e3de (diff) |
vorbisparse: error out when headers are missing
https://bugzilla.gnome.org/show_bug.cgi?id=791606
-rw-r--r-- | ext/vorbis/gstvorbisparse.c | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/ext/vorbis/gstvorbisparse.c b/ext/vorbis/gstvorbisparse.c index a91b0cb78..ada2b5ba5 100644 --- a/ext/vorbis/gstvorbisparse.c +++ b/ext/vorbis/gstvorbisparse.c @@ -178,7 +178,21 @@ vorbis_parse_drain_event_queue (GstVorbisParse * parse) } } -static void +static gboolean +vorbis_parse_have_header_packet (GstVorbisParse * parse, guint8 hdr_id) +{ + guint8 hdr; + GList *l; + + for (l = parse->streamheader; l != NULL; l = l->next) { + if (gst_buffer_extract (l->data, 0, &hdr, 1) == 1 && hdr == hdr_id) + return TRUE; + } + + return FALSE; +} + +static gboolean vorbis_parse_push_headers (GstVorbisParse * parse) { /* mark and put on caps */ @@ -186,6 +200,20 @@ vorbis_parse_push_headers (GstVorbisParse * parse) GstBuffer *outbuf, *outbuf1, *outbuf2, *outbuf3; ogg_packet packet; GstMapInfo map; + const gchar *hdr_name; + + /* Check we have enough header packets, and the right ones */ + hdr_name = "identification"; + if (!vorbis_parse_have_header_packet (parse, 1)) + goto missing_header; + + hdr_name = "comment"; + if (!vorbis_parse_have_header_packet (parse, 3)) + goto missing_header; + + hdr_name = "setup"; + if (!vorbis_parse_have_header_packet (parse, 5)) + goto missing_header; outbuf = GST_BUFFER_CAST (parse->streamheader->data); gst_buffer_map (outbuf, &map, GST_MAP_READ); @@ -244,6 +272,15 @@ vorbis_parse_push_headers (GstVorbisParse * parse) g_list_free (parse->streamheader); parse->streamheader = NULL; + return TRUE; + +/* ERRORS */ +missing_header: + { + GST_ELEMENT_ERROR (parse, STREAM, DECODE, (NULL), + ("Vorbis stream is missing %s header", hdr_name)); + return FALSE; + } } static void @@ -413,12 +450,17 @@ vorbis_parse_parse_packet (GstVorbisParse * parse, GstBuffer * buf) } else { /* data packet, push the headers we collected before */ if (!parse->streamheader_sent) { - vorbis_parse_push_headers (parse); + if (!vorbis_parse_push_headers (parse)) { + ret = GST_FLOW_ERROR; + goto out; + } parse->streamheader_sent = TRUE; } ret = vorbis_parse_queue_buffer (parse, buf); } +out: + return ret; } |