From a2320eb778b03b1cc251a0c41b3d49cf5d5176b5 Mon Sep 17 00:00:00 2001 From: conrad Date: Sat, 9 Feb 2008 03:23:40 +0000 Subject: [PATCH] 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 --- src/liboggz/oggz.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/liboggz/oggz.c b/src/liboggz/oggz.c index b1340bc..65fe38f 100644 --- a/src/liboggz/oggz.c +++ b/src/liboggz/oggz.c @@ -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 ********/ -- GitLab