From 9391daf9543835f2a5dd850cee422310d8e79449 Mon Sep 17 00:00:00 2001 From: nobu Date: Wed, 12 Sep 2007 06:19:06 +0000 Subject: * io.c (rb_io_s_sysopen): should not use alloca for unknowen size input. [ruby-dev:31775] * parse.y (rb_id2str): ditto. * marshal.c (w_float): use snprintf instead of sprintf. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13430 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- marshal.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'marshal.c') diff --git a/marshal.c b/marshal.c index 8d0f91c7f3..710068caa8 100644 --- a/marshal.c +++ b/marshal.c @@ -309,7 +309,7 @@ load_mantissa(double d, const char *buf, int len) static void w_float(double d, struct dump_arg *arg) { - char buf[100]; + char buf[FLOAT_DIG + (DECIMAL_MANT + 7) / 8 + 10]; if (isinf(d)) { if (d < 0) strcpy(buf, "-inf"); @@ -326,7 +326,7 @@ w_float(double d, struct dump_arg *arg) int len; /* xxx: should not use system's sprintf(3) */ - sprintf(buf, "%.*g", FLOAT_DIG, d); + snprintf(buf, sizeof(buf), "%.*g", FLOAT_DIG, d); len = strlen(buf); w_bytes(buf, len + save_mantissa(d, buf + len), arg); return; -- cgit v1.2.3