ruby-changes:29180
From: akr <ko1@a...>
Date: Tue, 11 Jun 2013 22:29:40 +0900 (JST)
Subject: [ruby-changes:29180] akr:r41232 (trunk): * bignum.c (validate_integer_pack_format): numwords argument added.
akr 2013-06-11 22:28:33 +0900 (Tue, 11 Jun 2013) New Revision: 41232 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=41232 Log: * bignum.c (validate_integer_pack_format): numwords argument added. Move a varidation from rb_integer_pack_internal and rb_integer_unpack. (rb_integer_pack_internal): Follow above change. (rb_integer_unpack): Ditto. Modified files: trunk/ChangeLog trunk/bignum.c Index: ChangeLog =================================================================== --- ChangeLog (revision 41231) +++ ChangeLog (revision 41232) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Tue Jun 11 22:25:04 2013 Tanaka Akira <akr@f...> + + * bignum.c (validate_integer_pack_format): numwords argument added. + Move a varidation from rb_integer_pack_internal and rb_integer_unpack. + (rb_integer_pack_internal): Follow above change. + (rb_integer_unpack): Ditto. + Tue Jun 11 20:52:43 2013 Tanaka Akira <akr@f...> * bignum.c (rb_integer_pack_internal): Renamed from rb_integer_pack Index: bignum.c =================================================================== --- bignum.c (revision 41231) +++ bignum.c (revision 41232) @@ -735,7 +735,7 @@ rb_absint_singlebit_p(VALUE val) https://github.com/ruby/ruby/blob/trunk/bignum.c#L735 INTEGER_PACK_NATIVE_BYTE_ORDER) static void -validate_integer_pack_format(size_t wordsize, size_t nails, int flags) +validate_integer_pack_format(size_t numwords, size_t wordsize, size_t nails, int flags) { int wordorder_bits = flags & INTEGER_PACK_WORDORDER_MASK; int byteorder_bits = flags & INTEGER_PACK_BYTEORDER_MASK; @@ -752,6 +752,8 @@ validate_integer_pack_format(size_t word https://github.com/ruby/ruby/blob/trunk/bignum.c#L752 rb_raise(rb_eArgError, "too big wordsize: %"PRI_SIZE_PREFIX"u", wordsize); if (wordsize <= nails / CHAR_BIT) rb_raise(rb_eArgError, "too big nails: %"PRI_SIZE_PREFIX"u", nails); + if (SIZE_MAX / wordsize < numwords) + rb_raise(rb_eArgError, "too big numwords * wordsize: %"PRI_SIZE_PREFIX"u * %"PRI_SIZE_PREFIX"u", numwords, wordsize); } static void @@ -852,9 +854,7 @@ rb_integer_pack_internal(VALUE val, void https://github.com/ruby/ruby/blob/trunk/bignum.c#L854 val = rb_to_int(val); - validate_integer_pack_format(wordsize, nails, flags); - if (SIZE_MAX / wordsize < numwords) - rb_raise(rb_eArgError, "too big numwords * wordsize: %"PRI_SIZE_PREFIX"u * %"PRI_SIZE_PREFIX"u", numwords, wordsize); + validate_integer_pack_format(numwords, wordsize, nails, flags); if (FIXNUM_P(val)) { long v = FIX2LONG(val); @@ -1207,9 +1207,7 @@ rb_integer_unpack(int sign, const void * https://github.com/ruby/ruby/blob/trunk/bignum.c#L1207 BDIGIT_DBL dd; int numbits_in_dd; - validate_integer_pack_format(wordsize, nails, flags); - if (SIZE_MAX / wordsize < numwords) - rb_raise(rb_eArgError, "too big numwords * wordsize: %"PRI_SIZE_PREFIX"u * %"PRI_SIZE_PREFIX"u", numwords, wordsize); + validate_integer_pack_format(numwords, wordsize, nails, flags); if (sign != 1 && sign != 0 && sign != -1) rb_raise(rb_eArgError, "unexpected sign: %d", sign); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/