summaryrefslogtreecommitdiffstats
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
commit46f0dbeacacd5e801fd3d83006889d83b2f3030f (patch)
treefdf0a518fac580ed0282df8472368963c19c147f /sprintf.c
parent71dfcea8e090c01d21975e9dc2d35135dd425028 (diff)
downloadruby-46f0dbeacacd5e801fd3d83006889d83b2f3030f.tar.gz
ruby-46f0dbeacacd5e801fd3d83006889d83b2f3030f.tar.xz
ruby-46f0dbeacacd5e801fd3d83006889d83b2f3030f.zip
* sprintf.c (rb_str_format): integer overflow check added.
* sprintf.c (GETASTER): ditto. git-svn-id: http://svn.ruby-lang.org/repos/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 dabdc93e7..eddb7c33c 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) {