From 987ec6b78778bf8c7fb0ec0eb1c0dc80bfda0d6a Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 6 Sep 2008 09:39:12 +0000 Subject: [PATCH] * transcode.c (allocate_converted_string): fix overflow condition. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@19183 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ transcode.c | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index a214a8ed07..eaf4bb2913 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sat Sep 6 18:38:47 2008 Tanaka Akira + + * transcode.c (allocate_converted_string): fix overflow condition. + Sat Sep 6 15:06:21 2008 Tanaka Akira * transcode.c (sym_html): new variable. diff --git a/transcode.c b/transcode.c index cc3fc53c7a..ccb54dfff0 100644 --- a/transcode.c +++ b/transcode.c @@ -1445,7 +1445,7 @@ allocate_converted_string(const char *sname, const char *dname, res = rb_econv_convert(ec, &sp, str+len, &dp, dst_str+dst_bufsize, 0); dst_len = dp - dst_str; while (res == econv_destination_buffer_full) { - if (dst_bufsize * 2 < dst_bufsize) { + if (SIZE_MAX/2 < dst_bufsize) { goto fail; } dst_bufsize *= 2;