From d5e02a7081cef509b3ca0796ba8d624fa039b173 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 7 Dec 2005 06:36:38 +0000 Subject: * sprintf.c (rb_str_format): integer overflow check added. * sprintf.c (GETASTER): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@9653 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- sprintf.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sprintf.c') diff --git a/sprintf.c b/sprintf.c index dabdc93e7e..eddb7c33ca 100644 --- a/sprintf.c +++ b/sprintf.c @@ -113,6 +113,9 @@ sign_bits(base, p) t = p++; \ n = 0; \ for (; p < end && ISDIGIT(*p); p++) { \ + if ((n*10) / 10 != n) { \ + rb_raise(rb_eArgError, #val " too big"); \ + } \ n = 10 * n + (*p - '0'); \ } \ if (p >= end) { \ @@ -309,6 +312,9 @@ rb_f_sprintf(argc, argv) case '5': case '6': case '7': case '8': case '9': n = 0; for (; p < end && ISDIGIT(*p); p++) { + if ((n*10) / 10 != n) { + rb_raise(rb_eArgError, "width too big"); + } n = 10 * n + (*p - '0'); } if (p >= end) { -- cgit v1.2.1