diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-30 10:42:40 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-11-30 10:42:40 +0000 |
commit | e46a61775933d1ce9207fde4422ad536fed4846a (patch) | |
tree | d54aa5d5f840daa3bd45a4e457ad88f43577b42a /ext/syck/rubyext.c | |
parent | 9497f7996a67fd4ef1a89292d84a9b89e86a829b (diff) | |
download | ruby-e46a61775933d1ce9207fde4422ad536fed4846a.tar.gz |
* ext/syck/rubyext.c (rb_syck_mktime): avoid segmentation fault.
[ruby-core:13735]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@14050 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/syck/rubyext.c')
-rw-r--r-- | ext/syck/rubyext.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/ext/syck/rubyext.c b/ext/syck/rubyext.c index 8e01bc176d..4ee1a30bee 100644 --- a/ext/syck/rubyext.c +++ b/ext/syck/rubyext.c @@ -262,9 +262,13 @@ rb_syck_mktime(char *str, long len) { char padded[] = "000000"; char *end = ptr + 1; + char *p = end; while ( isdigit( *end ) ) end++; - MEMCPY(padded, ptr + 1, char, end - (ptr + 1)); - usec = strtol(padded, NULL, 10); + if (end - p < sizeof(padded)) { + MEMCPY(padded, ptr + 1, char, end - (ptr + 1)); + p = padded; + } + usec = strtol(p, NULL, 10); } else { |