mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* marshal.c (r_bytes0): check if source has enough data.
[ruby-dev:32054] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13700 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
297d2e05cb
commit
14264f5f62
4 changed files with 29 additions and 4 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Oct 15 09:58:07 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* marshal.c (r_bytes0): check if source has enough data.
|
||||||
|
[ruby-dev:32054]
|
||||||
|
|
||||||
Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@fsij.org>
|
Mon Oct 15 01:15:09 2007 Tanaka Akira <akr@fsij.org>
|
||||||
|
|
||||||
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
|
* ext/socket/socket.c (s_accept_nonblock): make accepted fd
|
||||||
|
|
|
@ -929,7 +929,7 @@ r_bytes0(long len, struct load_arg *arg)
|
||||||
|
|
||||||
if (len == 0) return rb_str_new(0, 0);
|
if (len == 0) return rb_str_new(0, 0);
|
||||||
if (TYPE(arg->src) == T_STRING) {
|
if (TYPE(arg->src) == T_STRING) {
|
||||||
if (RSTRING_LEN(arg->src) > arg->offset) {
|
if (RSTRING_LEN(arg->src) > arg->offset + len) {
|
||||||
str = rb_str_new(RSTRING_PTR(arg->src)+arg->offset, len);
|
str = rb_str_new(RSTRING_PTR(arg->src)+arg->offset, len);
|
||||||
arg->offset += len;
|
arg->offset += len;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,24 @@ class TestMarshal < Test::Unit::TestCase
|
||||||
TestMarshal::StructInvalidMembers.members
|
TestMarshal::StructInvalidMembers.members
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class C
|
||||||
|
def initialize(str)
|
||||||
|
@str = str
|
||||||
|
end
|
||||||
|
def _dump(limit)
|
||||||
|
@str
|
||||||
|
end
|
||||||
|
def self._load(s)
|
||||||
|
new(s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def test_too_long_string
|
||||||
|
(data = Marshal.dump(C.new("a")))[-2, 1] = "\003\377\377\377"
|
||||||
|
e = assert_raise(ArgumentError, "[ruby-dev:32054]") {
|
||||||
|
Marshal.load(data)
|
||||||
|
}
|
||||||
|
assert_equal("marshal data too short", e.message)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#define RUBY_VERSION "1.9.0"
|
#define RUBY_VERSION "1.9.0"
|
||||||
#define RUBY_RELEASE_DATE "2007-10-14"
|
#define RUBY_RELEASE_DATE "2007-10-15"
|
||||||
#define RUBY_VERSION_CODE 190
|
#define RUBY_VERSION_CODE 190
|
||||||
#define RUBY_RELEASE_CODE 20071014
|
#define RUBY_RELEASE_CODE 20071015
|
||||||
#define RUBY_PATCHLEVEL 0
|
#define RUBY_PATCHLEVEL 0
|
||||||
|
|
||||||
#define RUBY_VERSION_MAJOR 1
|
#define RUBY_VERSION_MAJOR 1
|
||||||
|
@ -9,7 +9,7 @@
|
||||||
#define RUBY_VERSION_TEENY 0
|
#define RUBY_VERSION_TEENY 0
|
||||||
#define RUBY_RELEASE_YEAR 2007
|
#define RUBY_RELEASE_YEAR 2007
|
||||||
#define RUBY_RELEASE_MONTH 10
|
#define RUBY_RELEASE_MONTH 10
|
||||||
#define RUBY_RELEASE_DAY 14
|
#define RUBY_RELEASE_DAY 15
|
||||||
|
|
||||||
#ifdef RUBY_EXTERN
|
#ifdef RUBY_EXTERN
|
||||||
RUBY_EXTERN const char ruby_version[];
|
RUBY_EXTERN const char ruby_version[];
|
||||||
|
|
Loading…
Reference in a new issue