ruby-changes:2559
From: ko1@a...
Date: 30 Nov 2007 19:42:57 +0900
Subject: [ruby-changes:2559] matz - Ruby:r14050 (trunk): * ext/syck/rubyext.c (rb_syck_mktime): avoid segmentation fault.
matz 2007-11-30 19:42:40 +0900 (Fri, 30 Nov 2007) New Revision: 14050 Modified files: trunk/ChangeLog trunk/bootstraptest/test_knownbug.rb trunk/ext/syck/rubyext.c Log: * ext/syck/rubyext.c (rb_syck_mktime): avoid segmentation fault. [ruby-core:13735] http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=14050&r2=14049 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ext/syck/rubyext.c?r1=14050&r2=14049 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/bootstraptest/test_knownbug.rb?r1=14050&r2=14049 Index: ChangeLog =================================================================== --- ChangeLog (revision 14049) +++ ChangeLog (revision 14050) @@ -1,3 +1,8 @@ +Fri Nov 30 19:33:38 2007 Yukihiro Matsumoto <matz@r...> + + * ext/syck/rubyext.c (rb_syck_mktime): avoid segmentation fault. + [ruby-core:13735] + Fri Nov 30 19:05:55 2007 Yukihiro Matsumoto <matz@r...> * enum.c (enum_count): precise argument number check. Index: bootstraptest/test_knownbug.rb =================================================================== --- bootstraptest/test_knownbug.rb (revision 14049) +++ bootstraptest/test_knownbug.rb (revision 14050) @@ -3,6 +3,7 @@ # So all tests will cause failure. # +$:.unshift File.join(File.dirname(__FILE__), "../.ext/#{RUBY_PLATFORM}") assert_normal_exit %q{ STDERR.reopen(STDOUT) require 'yaml' Index: ext/syck/rubyext.c =================================================================== --- ext/syck/rubyext.c (revision 14049) +++ ext/syck/rubyext.c (revision 14050) @@ -262,9 +262,13 @@ { 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 { -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml