ruby-changes:12332
From: nobu <ko1@a...>
Date: Sat, 11 Jul 2009 00:16:50 +0900 (JST)
Subject: [ruby-changes:12332] Ruby:r24027 (trunk): * random.c (rand_init): got rid of buffer overflow.
nobu 2009-07-11 00:16:32 +0900 (Sat, 11 Jul 2009) New Revision: 24027 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=24027 Log: * random.c (rand_init): got rid of buffer overflow. Modified files: trunk/ChangeLog trunk/random.c Index: ChangeLog =================================================================== --- ChangeLog (revision 24026) +++ ChangeLog (revision 24027) @@ -1,3 +1,7 @@ +Sat Jul 11 00:16:27 2009 Nobuyoshi Nakada <nobu@r...> + + * random.c (rand_init): got rid of buffer overflow. + Sat Jul 11 00:11:38 2009 Nobuyoshi Nakada <nobu@r...> * array.c (ary_join_1): should recurse for element array. Index: random.c =================================================================== --- random.c (revision 24026) +++ random.c (revision 24027) @@ -253,11 +253,11 @@ } len = (len + 3) / 4; /* number of 32bit words */ buf = ALLOC_N(unsigned int, len); /* allocate longs for init_by_array */ - memset(buf, 0, len * sizeof(long)); + memset(buf, 0, len * sizeof(int)); if (FIXNUM_P(seed)) { - buf[0] = (unsigned int)(FIX2ULONG(seed) & 0xffffffff); + buf[0] = (unsigned int)(FIX2ULONG(seed) & 0xffffffff); #if SIZEOF_LONG > 4 - buf[1] = (unsigned int)(FIX2ULONG(seed) >> 32); + buf[1] = (unsigned int)(FIX2ULONG(seed) >> 32); #endif } else { @@ -322,7 +322,7 @@ seed[0] ^= tv.tv_usec; seed[1] ^= (unsigned int)tv.tv_sec; #if SIZEOF_TIME_T > SIZEOF_INT - seed[1] ^= (unsigned int)(tv.tv_sec >> SIZEOF_INT * CHAR_BIT); + seed[0] ^= (unsigned int)(tv.tv_sec >> SIZEOF_INT * CHAR_BIT); #endif seed[2] ^= getpid() ^ (n++ << 16); seed[3] ^= (unsigned int)(VALUE)&seed; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/