diff options
author | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-14 05:05:17 +0000 |
---|---|---|
committer | gotoyuzo <gotoyuzo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-12-14 05:05:17 +0000 |
commit | 52c74c8a47c7303a63a60c4fe31936a093312def (patch) | |
tree | 5c099a5e76fbc1ef69abef59f114e4d2376c77dd /ext/openssl | |
parent | 8bc24f18d2816b9e067a26debbfa734909878623 (diff) | |
download | ruby-52c74c8a47c7303a63a60c4fe31936a093312def.tar.gz ruby-52c74c8a47c7303a63a60c4fe31936a093312def.tar.xz ruby-52c74c8a47c7303a63a60c4fe31936a093312def.zip |
* ext/openssl/ossl.c (ossl_raise): avoid buffer overrun. [ruby-dev:25187]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7550 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/ossl.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 36a7aa504..133b4e30c 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)); } |