From 604b9367ee7a77aeff916a6bb5a9ee9601d72c02 Mon Sep 17 00:00:00 2001 From: Kevin Croft Date: Sat, 17 Nov 2018 21:42:30 -0800 Subject: [PATCH] Add detection for Ogg skeleton metadata --- stb_vorbis.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/stb_vorbis.c b/stb_vorbis.c index b1a8b22..da3156a 100644 --- a/stb_vorbis.c +++ b/stb_vorbis.c @@ -374,7 +374,8 @@ enum STBVorbisError VORBIS_invalid_first_page, VORBIS_bad_packet_type, VORBIS_cant_find_last_page, - VORBIS_seek_failed + VORBIS_seek_failed, + VORBIS_ogg_skeleton_not_supported }; @@ -3579,6 +3580,18 @@ static int start_decoder(vorb *f) // check for expected packet length if (f->segment_count != 1) return error(f, VORBIS_invalid_first_page); if (f->segments[0] != 30) return error(f, VORBIS_invalid_first_page); + // check for the Ogg skeleton fishead identifying header to refine our error + if (f->segments[0] == 64 && + getn(f, header, 6) && + header[0] == 'f' && + header[1] == 'i' && + header[2] == 's' && + header[3] == 'h' && + header[4] == 'e' && + header[5] == 'a' && + get8(f) == 'd') return error(f, VORBIS_ogg_skeleton_not_supported); + else + return error(f, VORBIS_invalid_first_page); // read packet // check packet header if (get8(f) != VORBIS_packet_id) return error(f, VORBIS_invalid_first_page);