summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-17 17:56:41 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-17 17:56:41 +0000
commita0e236f6065e5dfd68ac8a45ad1ca690042d47b9 (patch)
tree90f0288ab5d9d74e5a9eda04d0e6e1c43b7b701a
parent04351d95585db8baee7cbcf0cf6939cb3cbeaf6c (diff)
* pack.c (pack_pack): check errno to detect error of ruby_strtoul.
* pack.c (pack_unpack): ditto. * test/ruby/test_pack.rb: add a test for above. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16452 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog8
-rw-r--r--pack.c9
-rw-r--r--test/ruby/test_pack.rb4
-rw-r--r--version.h6
4 files changed, 24 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index c8388a2..214413a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+Sun May 18 02:54:46 2008 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * pack.c (pack_pack): check errno to detect error of ruby_strtoul.
+
+ * pack.c (pack_unpack): ditto.
+
+ * test/ruby/test_pack.rb: add a test for above.
+
Sat May 17 23:53:57 2008 Nobuyoshi Nakada <nobu@ruby-lang.org>
* file.c (file_expand_path): fix for short file name on Cygwin.
diff --git a/pack.c b/pack.c
index c5a5337..255f74d 100644
--- a/pack.c
+++ b/pack.c
@@ -12,6 +12,7 @@
#include "ruby/ruby.h"
#include <sys/types.h>
#include <ctype.h>
+#include <errno.h>
#define SIZE16 2
#define SIZE32 4
@@ -491,7 +492,11 @@ pack_pack(VALUE ary, VALUE fmt)
p++;
}
else if (ISDIGIT(*p)) {
+ errno = 0;
len = STRTOUL(p, (char**)&p, 10);
+ if (errno) {
+ rb_raise(rb_eRangeError, "pack length too big");
+ }
}
else {
len = 1;
@@ -1350,7 +1355,11 @@ pack_unpack(VALUE str, VALUE fmt)
p++;
}
else if (ISDIGIT(*p)) {
+ errno = 0;
len = STRTOUL(p, (char**)&p, 10);
+ if (errno) {
+ rb_raise(rb_eRangeError, "pack length too big");
+ }
}
else {
len = (type != '@');
diff --git a/test/ruby/test_pack.rb b/test/ruby/test_pack.rb
index b388937..30ffe13 100644
--- a/test/ruby/test_pack.rb
+++ b/test/ruby/test_pack.rb
@@ -441,4 +441,8 @@ class TestPack < Test::Unit::TestCase
end.join
end
end
+
+ def test_length_too_big
+ assert_raise(RangeError) { [].pack("C100000000000000000000") }
+ end
end
diff --git a/version.h b/version.h
index 858d8b6..e131064 100644
--- a/version.h
+++ b/version.h
@@ -1,7 +1,7 @@
#define RUBY_VERSION "1.9.0"
-#define RUBY_RELEASE_DATE "2008-05-17"
+#define RUBY_RELEASE_DATE "2008-05-18"
#define RUBY_VERSION_CODE 190
-#define RUBY_RELEASE_CODE 20080517
+#define RUBY_RELEASE_CODE 20080518
#define RUBY_PATCHLEVEL 0
#define RUBY_VERSION_MAJOR 1
@@ -9,7 +9,7 @@
#define RUBY_VERSION_TEENY 0
#define RUBY_RELEASE_YEAR 2008
#define RUBY_RELEASE_MONTH 5
-#define RUBY_RELEASE_DAY 17
+#define RUBY_RELEASE_DAY 18
#ifdef RUBY_EXTERN
RUBY_EXTERN const char ruby_version[];