aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--ChangeLog4
-rw-r--r--bignum.c11
2 files changed, 8 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index cce1f81535..021cfdeb83 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Wed Jun 26 07:27:17 2013 Tanaka Akira <akr@fsij.org>
+
+ * bignum.c (bigand_int): Fix a buffer over read.
+
Wed Jun 26 06:48:07 2013 Tanaka Akira <akr@fsij.org>
* bignum.c (bigadd_int): Fix a buffer over read.
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) {