Commit 1f4fb0e5 authored by conrad's avatar conrad

Check that serialnos passed to oggz_write_feed() fit within the 32 bit range,

returning OGGZ_ERR_BAD_SERIALNO otherwise (as for unknown serialnos).
+ Explicitly use ogg_int32_t for generating serialnos in oggz_serialno_new().


git-svn-id: http://svn.annodex.net/liboggz/trunk@3418 8158c8cd-e7e1-0310-9fa4-c5954c97daef
parent a2320eb7
......@@ -173,6 +173,8 @@ int oggz_write_set_hungry_callback (OGGZ * oggz,
* \retval OGGZ_ERR_BAD_SERIALNO \a serialno does not identify an existing
* logical bitstream in \a oggz,
* and \a oggz is not flagged OGGZ_NONSTRICT
* or \a serialno is equal to -1, or \a serialno does not fit in
* 32 bits, ie. within the range (-(2^31), (2^31)-1)
* \retval OGGZ_ERR_BAD_OGGZ \a oggz does not refer to an existing OGGZ
* \retval OGGZ_ERR_INVALID Operation not suitable for this OGGZ
*
......
......@@ -459,7 +459,7 @@ oggz_serialno_new (OGGZ * oggz)
* 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;
static ogg_int32_t serialno = 0;
int k;
if (serialno == 0) serialno = time(NULL);
......
......@@ -223,6 +223,15 @@ oggz_write_feed (OGGZ * oggz, ogg_packet * op, long serialno, int flush,
if (guard && *guard != 0) return OGGZ_ERR_BAD_GUARD;
/* Check that the serialno is in the valid range for an Ogg page header,
* ie. that it fits within 32 bits and does not equal the special value -1 */
if ((serialno & 0xffffffff) != serialno || serialno == -1) {
#ifdef DEBUG
printf ("oggz_write_feed: serialno %010ld\n", serialno);
#endif
return OGGZ_ERR_BAD_SERIALNO;
}
#ifdef DEBUG
printf ("oggz_write_feed: (%010ld) FLUSH: %d\n", serialno, flush);
#endif
......
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