aboutsummaryrefslogtreecommitdiffstats
path: root/bignum.c
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-25 22:28:43 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-25 22:28:43 +0000
commit3ade5353e1f7a8893443ade7182851edac891295 (patch)
tree204b4d1bbf808bd0ff6e63309ccf483ea833d375 /bignum.c
parent5026d0ae752018bfda74ee04c11f755b7b6adddb (diff)
downloadruby-3ade5353e1f7a8893443ade7182851edac891295.tar.gz
* bignum.c (bigand_int): Fix a buffer over read.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41637 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r--bignum.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/bignum.c b/bignum.c
index 750fd84b43..7e36ccbb15 100644
--- a/bignum.c
+++ b/bignum.c
@@ -4651,13 +4651,10 @@ bigand_int(VALUE x, long y)
i = 1;
zds[0] = xds[0] & y;
#else
- {
- long num = y;
-
- for (i=0; i<bdigit_roomof(SIZEOF_LONG); i++) {
- zds[i] = xds[i] & BIGLO(num);
- num = BIGDN(num);
- }
+ for (i=0; i < xn; i++) {
+ if (y == 0 || y == -1) break;
+ zds[i] = xds[i] & BIGLO(y);
+ y = BIGDN(y);
}
#endif
while (i < xn) {