ruby-changes:35518
From: nobu <ko1@a...>
Date: Tue, 16 Sep 2014 11:44:16 +0900 (JST)
Subject: [ruby-changes:35518] nobu:r47600 (trunk): sprintf.c: integer overflow
nobu 2014-09-16 11:44:04 +0900 (Tue, 16 Sep 2014) New Revision: 47600 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=47600 Log: sprintf.c: integer overflow * sprintf.c (rb_str_format): fix a possible integer overflow and suppress implicit conversion warnings. Modified files: trunk/sprintf.c Index: sprintf.c =================================================================== --- sprintf.c (revision 47599) +++ sprintf.c (revision 47600) @@ -1026,8 +1026,8 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1026 { VALUE val = GETARG(), num, den; int sign = (flags&FPLUS) ? 1 : 0, zero = 0; - long len; - int i, done = 0, prefix = 0; + long len, done = 0; + int prefix = 0; if (!RB_TYPE_P(val, T_RATIONAL)) { nextvalue = val; goto float_value; @@ -1100,7 +1100,7 @@ rb_str_format(int argc, const VALUE *arg https://github.com/ruby/ruby/blob/trunk/sprintf.c#L1100 } if ((flags & FWIDTH) && width > done) { if (!(flags&FMINUS)) { - int shifting = (flags&FZERO) ? done - prefix : done; + long i, shifting = (flags&FZERO) ? done - prefix : done; for (i = 1; i <= shifting; i++) buf[width - i] = buf[done - i]; blen -= shifting; -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/