ruby-changes:3876
From: ko1@a...
Date: Sat, 2 Feb 2008 09:32:55 +0900 (JST)
Subject: [ruby-changes:3876] akr - Ruby:r15365 (trunk): * random.c (limited_big_rand): fix buffer overflow when SIZEOF_BDIGITS
akr 2008-02-02 09:32:40 +0900 (Sat, 02 Feb 2008) New Revision: 15365 Modified files: trunk/ChangeLog trunk/random.c Log: * random.c (limited_big_rand): fix buffer overflow when SIZEOF_BDIGITS is 2. fixed by Kenta Murata. [ruby-dev:33565] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=15365&r2=15364&diff_format=u http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/random.c?r1=15365&r2=15364&diff_format=u Index: ChangeLog =================================================================== --- ChangeLog (revision 15364) +++ ChangeLog (revision 15365) @@ -1,3 +1,8 @@ +Sat Feb 2 09:28:36 2008 Tanaka Akira <akr@f...> + + * random.c (limited_big_rand): fix buffer overflow when SIZEOF_BDIGITS + is 2. fixed by Kenta Murata. [ruby-dev:33565] + Fri Feb 1 21:42:37 2008 Nobuyoshi Nakada <nobu@r...> * configure.in (darwin): _XOPEN_SOURCE is necessary to make ucontext_t Index: random.c =================================================================== --- random.c (revision 15364) +++ random.c (revision 15365) @@ -385,12 +385,16 @@ val = (struct RBignum *)rb_big_clone((VALUE)limit); RBIGNUM_SET_SIGN(val, 1); #if SIZEOF_BDIGITS == 2 -# define BIG_GET32(big,i) (RBIGNUM_DIGITS(big)[(i)*2] | \ - ((i)*2+1 < RBIGNUM_DIGITS(big) ? (RBIGNUM_DIGITS(big)[(i)*2+1] << 16) \ - : 0)) -# define BIG_SET32(big,i,d) ((RBIGNUM_DIGITS(big)[(i)*2] = (d) & 0xffff), \ - ((i)*2+1 < RBIGNUM_DIGITS(big) ? (RBIGNUM_DIGITS(big)[(i)*2+1] = (d) >> 16) \ - : 0)) +# define BIG_GET32(big,i) \ + (RBIGNUM_DIGITS(big)[(i)*2] | \ + ((i)*2+1 < RBIGNUM_LEN(big) ? \ + (RBIGNUM_DIGITS(big)[(i)*2+1] << 16) : \ + 0)) +# define BIG_SET32(big,i,d) \ + ((RBIGNUM_DIGITS(big)[(i)*2] = (d) & 0xffff), \ + ((i)*2+1 < RBIGNUM_LEN(big) ? \ + (RBIGNUM_DIGITS(big)[(i)*2+1] = (d) >> 16) : \ + 0)) #else /* SIZEOF_BDIGITS == 4 */ # define BIG_GET32(big,i) (RBIGNUM_DIGITS(big)[i]) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/