[xiph-commits] r3418 - in liboggz/trunk: include/oggz src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Fri Feb 8 20:00:26 PST 2008


Author: conrad
Date: 2008-02-08 20:00:24 -0800 (Fri, 08 Feb 2008)
New Revision: 3418

Modified:
   liboggz/trunk/include/oggz/oggz_write.h
   liboggz/trunk/src/liboggz/oggz.c
   liboggz/trunk/src/liboggz/oggz_write.c
Log:
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().


Modified: liboggz/trunk/include/oggz/oggz_write.h
===================================================================
--- liboggz/trunk/include/oggz/oggz_write.h	2008-02-09 03:23:40 UTC (rev 3417)
+++ liboggz/trunk/include/oggz/oggz_write.h	2008-02-09 04:00:24 UTC (rev 3418)
@@ -173,6 +173,8 @@
  * \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
  *

Modified: liboggz/trunk/src/liboggz/oggz.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz.c	2008-02-09 03:23:40 UTC (rev 3417)
+++ liboggz/trunk/src/liboggz/oggz.c	2008-02-09 04:00:24 UTC (rev 3418)
@@ -459,7 +459,7 @@
    * 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);

Modified: liboggz/trunk/src/liboggz/oggz_write.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz_write.c	2008-02-09 03:23:40 UTC (rev 3417)
+++ liboggz/trunk/src/liboggz/oggz_write.c	2008-02-09 04:00:24 UTC (rev 3418)
@@ -223,7 +223,16 @@
 
   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
 



More information about the commits mailing list