Commit 6aa040a7 authored by conrad's avatar conrad

oggz_read: return an error when a hole (ie. missing sequence number) is detected

in the headers of a track, as such header corruption cannot be tolerated by decoders.
Beyond the headers, skip holes in data as before for robustness.

This should fix Mozilla bug 463756: https://bugzilla.mozilla.org/show_bug.cgi?id=463756
which crashed in vorbis_synthesize() after attempting to decode with corrupt headers.
The method of this fix is adapted from libvorbisfile, but here should work for any
content type. Tested with the file attached to the above bug, with fishsound-info
and oggplay-info, both of which previously crashed.


git-svn-id: http://svn.annodex.net/liboggz/trunk@3773 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent d08c55c1
......@@ -170,6 +170,9 @@ enum OggzError {
/** no data available from IO, try again */
OGGZ_ERR_IO_AGAIN = -16,
/** Hole (sequence number gap) detected in input data */
OGGZ_ERR_HOLE_IN_DATA = -17,
/** The requested serialno does not exist in this OGGZ */
OGGZ_ERR_BAD_SERIALNO = -20,
......
......@@ -374,23 +374,29 @@ oggz_read_sync (OGGZ * oggz)
result = ogg_stream_packetout(os, op);
/*
* libogg flags "holes in the data" (which are really inconsistencies
* in the page sequence number) by returning -1.
*/
if(result == -1) {
#ifdef DEBUG
printf ("oggz_read_sync: hole in the data\n");
#endif
/* We can't tolerate holes in headers, so bail out. */
if (stream->packetno < 3) return OGGZ_ERR_HOLE_IN_DATA;
/* Holes in content occur in some files and pretty much don't matter,
* so we silently swallow the notification and reget the packet.
*/
result = ogg_stream_packetout(os, op);
if (result == -1) {
#ifdef DEBUG
/*
* libogg flags "holes in the data" (which are really
* inconsistencies in the page sequence number) by returning
* -1. This occurs in some files and pretty much doesn't matter,
* so we silently swallow the notification and reget the packet.
* If the result is *still* -1 then something strange is happening.
/* If the result is *still* -1 then something strange is
* happening.
*/
printf ("shouldn't get here");
#ifdef DEBUG
printf ("Multiple holes in data!");
#endif
return -7;
return OGGZ_ERR_HOLE_IN_DATA;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment