ruby-changes:18975
From: naruse <ko1@a...>
Date: Thu, 3 Mar 2011 16:13:17 +0900 (JST)
Subject: [ruby-changes:18975] Ruby:r31011 (trunk): * strftime.c (STRFTIME): return 0 and ERANGE when precision is too
naruse 2011-03-03 14:28:00 +0900 (Thu, 03 Mar 2011) New Revision: 31011 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=31011 Log: * strftime.c (STRFTIME): return 0 and ERANGE when precision is too large. [ruby-dev:43284] fixes #4456 Modified files: trunk/ChangeLog trunk/strftime.c Index: ChangeLog =================================================================== --- ChangeLog (revision 31010) +++ ChangeLog (revision 31011) @@ -1,3 +1,8 @@ +Thu Mar 3 14:25:19 2011 NARUSE, Yui <naruse@r...> + + * strftime.c (STRFTIME): return 0 and ERANGE when precision is too + large. [ruby-dev:43284] fixes #4456 + Thu Mar 3 00:46:51 2011 NARUSE, Yui <naruse@r...> * addr2line.c (uleb128): cast the value to unsigned long. Index: strftime.c =================================================================== --- strftime.c (revision 31010) +++ strftime.c (revision 31011) @@ -237,6 +237,10 @@ i = rb_strftime_with_timespec(s, endp - s, (fmt), vtm, timev, ts, gmt); \ if (!i) return 0; \ if (precision > i) {\ + if (start + maxsize < s + precision) { \ + errno = ERANGE; \ + return 0; \ + } \ memmove(s + precision - i, s, i);\ memset(s, padding ? padding : ' ', precision - i); \ s += precision; \ -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/