Commit a2320eb7 authored by conrad's avatar conrad

Ensure that serialno's generated by oggz_serialno_new() are within the range

of an int, so that they pass cleanly through ogg_stream_init(). Passes
'make check' on 64bit, failure reported by Jean-Marc Valin. Tested on x86_64.
As the size of a serialno in the Ogg page header is 32 bits, it should never
have been declared a long in ogg.h's ogg_packet in the first place ...


git-svn-id: http://svn.annodex.net/liboggz/trunk@3417 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent 1c0d94bd
......@@ -455,7 +455,11 @@ oggz_get_numtracks (OGGZ * oggz)
long
oggz_serialno_new (OGGZ * oggz)
{
static long serialno = 0;
/* Ensure that the returned value is within the range of an int, so that
* it passes cleanly through ogg_stream_init(). In any case, the size of
* a serialno in the Ogg page header is 32 bits; it should never have been
* declared a long in ogg.h's ogg_packet in the first place. */
static int serialno = 0;
int k;
if (serialno == 0) serialno = time(NULL);
......@@ -465,7 +469,8 @@ oggz_serialno_new (OGGZ * oggz)
serialno = 11117 * serialno + 211231;
} while (serialno == -1 || oggz_get_stream (oggz, serialno) != NULL);
return serialno;
/* Cast the result back to a long for API consistency */
return (long)serialno;
}
/******** OggzMetric management ********/
......
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