[xiph-commits] r3417 - liboggz/trunk/src/liboggz

conrad at svn.annodex.net conrad at svn.annodex.net
Fri Feb 8 19:23:44 PST 2008


Author: conrad
Date: 2008-02-08 19:23:40 -0800 (Fri, 08 Feb 2008)
New Revision: 3417

Modified:
   liboggz/trunk/src/liboggz/oggz.c
Log:
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 ...


Modified: liboggz/trunk/src/liboggz/oggz.c
===================================================================
--- liboggz/trunk/src/liboggz/oggz.c	2008-02-09 02:27:37 UTC (rev 3416)
+++ liboggz/trunk/src/liboggz/oggz.c	2008-02-09 03:23:40 UTC (rev 3417)
@@ -455,7 +455,11 @@
 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 @@
       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 ********/



More information about the commits mailing list