summaryrefslogtreecommitdiffstats
path: root/variable.c
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:25:39 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-07-19 08:25:39 +0000
commit5db2d745164db6c375edd86a5bb28eeb6041d7c0 (patch)
treee91a96aa41166abd1bd8c531fb548999fde63869 /variable.c
parentb693f0f55c7e67f6ef907492fb89d5788af1fe81 (diff)
downloadruby-5db2d745164db6c375edd86a5bb28eeb6041d7c0.tar.gz
ruby-5db2d745164db6c375edd86a5bb28eeb6041d7c0.tar.xz
ruby-5db2d745164db6c375edd86a5bb28eeb6041d7c0.zip
* io.c (rb_io_inspect): replace sprintf() with "%s" format all
over the place by snprintf() to avoid integer overflow. * sample/svr.rb: service can be stopped by ill-behaved client; use tsvr.rb instead. git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8799 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'variable.c')
-rw-r--r--variable.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/variable.c b/variable.c
index 04d826bf2..7e56e8df8 100644
--- a/variable.c
+++ b/variable.c
@@ -196,6 +196,7 @@ rb_class_path(klass)
}
else {
char *s = "Class";
+ size_t len;
if (TYPE(klass) == T_MODULE) {
if (rb_obj_class(klass) == rb_cModule) {
@@ -205,8 +206,9 @@ rb_class_path(klass)
s = rb_class2name(RBASIC(klass)->klass);
}
}
- path = rb_str_new(0, 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1);
- sprintf(RSTRING(path)->ptr, "#<%s:0x%lx>", s, klass);
+ len = 2 + strlen(s) + 3 + 2 * SIZEOF_LONG + 1;
+ path = rb_str_new(0, len);
+ snprintf(RSTRING(path)->ptr, len, "#<%s:0x%lx>", s, klass);
RSTRING(path)->len = strlen(RSTRING(path)->ptr);
rb_ivar_set(klass, tmp_classpath, path);