summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-14 05:05:17 +0000
committergotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-12-14 05:05:17 +0000
commit08dc317502511db1d0d48fa51742aa8bbb58e8de (patch)
tree936ad1bf5fdac120262ab2d98e54ed430fd9fb08
parent293534986f336e9f65ba9d8f9f66fcd86607eca7 (diff)
* ext/openssl/ossl.c (ossl_raise): avoid buffer overrun. [ruby-dev:25187]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@7550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--ext/openssl/ossl.c6
2 files changed, 8 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 1bbcddc963..8b728e093a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Dec 14 14:03:57 2004 GOTOU Yuuzou <gotoyuzo@notwork.org>
+
+ * ext/openssl/ossl.c (ossl_raise): avoid buffer overrun.
+ [ruby-dev:25187]
+
Mon Dec 13 18:13:52 2004 Tanaka Akira <akr@m17n.org>
* gc.c (stack_end_address): new function to obtain stack end address.
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 36a7aa5042..133b4e30ca 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -285,17 +285,17 @@ ossl_raise(VALUE exc, const char *fmt, ...)
va_start(args, fmt);
len = vsnprintf(buf, BUFSIZ, fmt, args);
va_end(args);
- len += snprintf(buf+len, BUFSIZ-len, ": ");
}
- if (e) {
+ if (len < BUFSIZ && e) {
if (dOSSL == Qtrue) /* FULL INFO */
msg = ERR_error_string(e, NULL);
else
msg = ERR_reason_error_string(e);
ERR_clear_error();
- len += snprintf(buf+len, BUFSIZ-len, "%s", msg);
+ len += snprintf(buf+len, BUFSIZ-len, ": %s", msg);
}
+ if(len > BUFSIZ) len = strlen(buf);
rb_exc_raise(rb_exc_new(exc, buf, len));
}