Last active
December 29, 2015 08:59
Backport patch for Ruby Enterprise Edition 1.8.7-2012.02 for the CVE-2013-4164 DOS Vulnerability
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff -ru a/source/test/ruby/test_float.rb b/source/test/ruby/test_float.rb | |
--- a/source/test/ruby/test_float.rb 2012-02-19 07:09:11.000000000 -0700 | |
+++ b/source/test/ruby/test_float.rb 2013-11-25 11:51:15.000000000 -0700 | |
@@ -171,4 +171,16 @@ | |
assert_raise(ArgumentError) { 1.0 < nil } | |
assert_raise(ArgumentError) { 1.0 <= nil } | |
end | |
+ | |
+ def test_long_string | |
+ assert_normal_exit(<<-'end;') | |
+ assert_in_epsilon(10.0, ("1."+"1"*300000).to_f*9) | |
+ end; | |
+ end | |
end | |
diff -ru a/source/util.c b/source/util.c | |
--- a/source/util.c 2012-02-19 07:09:11.000000000 -0700 | |
+++ b/source/util.c 2013-11-25 11:51:15.000000000 -0700 | |
@@ -892,6 +892,11 @@ | |
#else | |
#define MALLOC malloc | |
#endif | |
+#ifdef FREE | |
+extern void FREE(void*); | |
+#else | |
+#define FREE free | |
+#endif | |
#ifndef Omit_Private_Memory | |
#ifndef PRIVATE_MEM | |
@@ -1176,7 +1181,7 @@ | |
#endif | |
ACQUIRE_DTOA_LOCK(0); | |
- if ((rv = freelist[k]) != 0) { | |
+ if (k <= Kmax && (rv = freelist[k]) != 0) { | |
freelist[k] = rv->next; | |
} | |
else { | |
@@ -1186,7 +1191,7 @@ | |
#else | |
len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) | |
/sizeof(double); | |
- if (pmem_next - private_mem + len <= PRIVATE_mem) { | |
+ if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { | |
rv = (Bigint*)pmem_next; | |
pmem_next += len; | |
} | |
@@ -1205,6 +1210,10 @@ | |
Bfree(Bigint *v) | |
{ | |
if (v) { | |
+ if (v->k > Kmax) { | |
+ FREE(v); | |
+ return; | |
+ } | |
ACQUIRE_DTOA_LOCK(0); | |
v->next = freelist[v->k]; | |
freelist[v->k] = v; | |
@@ -2200,6 +2209,7 @@ | |
for (; c >= '0' && c <= '9'; c = *++s) { | |
have_dig: | |
nz++; | |
+ if (nf > DBL_DIG * 4) continue; | |
if (c -= '0') { | |
nf += nz; | |
for (i = 1; i < nz; i++) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment