summaryrefslogtreecommitdiff
path: root/sprintf.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 06:36:38 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-12-07 06:36:38 +0000
commitd5e02a7081cef509b3ca0796ba8d624fa039b173 (patch)
treefdf0a518fac580ed0282df8472368963c19c147f /sprintf.c
parent9b85df19a16c1a5fd99316e385c7c2a7b621fdf0 (diff)
* 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
Diffstat (limited to 'sprintf.c')
-rw-r--r--sprintf.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sprintf.c b/sprintf.c
index dabdc93..eddb7c3 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) {