aboutsummaryrefslogtreecommitdiffstats
path: root/ext/openssl/ossl.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-12 08:11:36 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-12 08:11:36 +0000
commit9bd672f6682aef683c49f0b8da2b439e4d4103ac (patch)
tree17a6f91b7e705c4ba7bf32e6ceadd136e7b595f5 /ext/openssl/ossl.c
parent42406852371bdf3fe3d2e4e51192c87720a8e568 (diff)
downloadruby-9bd672f6682aef683c49f0b8da2b439e4d4103ac.tar.gz
ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44572 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl/ossl.c')
-rw-r--r--ext/openssl/ossl.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c
index 689f21ae0f..614d2fa6f7 100644
--- a/ext/openssl/ossl.c
+++ b/ext/openssl/ossl.c
@@ -294,10 +294,9 @@ ossl_to_der_if_possible(VALUE obj)
static VALUE
ossl_make_error(VALUE exc, const char *fmt, va_list args)
{
- char buf[BUFSIZ];
+ VALUE str = Qnil;
const char *msg;
long e;
- int len = 0;
#ifdef HAVE_ERR_PEEK_LAST_ERROR
e = ERR_peek_last_error();
@@ -305,14 +304,19 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
e = ERR_peek_error();
#endif
if (fmt) {
- len = vsnprintf(buf, BUFSIZ, fmt, args);
+ str = rb_vsprintf(fmt, args);
}
- if (len < BUFSIZ && e) {
+ if (e) {
if (dOSSL == Qtrue) /* FULL INFO */
msg = ERR_error_string(e, NULL);
else
msg = ERR_reason_error_string(e);
- len += snprintf(buf+len, BUFSIZ-len, "%s%s", (len ? ": " : ""), msg);
+ if (NIL_P(str)) {
+ str = rb_str_new_cstr(msg);
+ }
+ else {
+ rb_str_cat2(rb_str_cat2(str, ": "), msg);
+ }
}
if (dOSSL == Qtrue){ /* show all errors on the stack */
while ((e = ERR_get_error()) != 0){
@@ -321,8 +325,8 @@ ossl_make_error(VALUE exc, const char *fmt, va_list args)
}
ERR_clear_error();
- if(len > BUFSIZ) len = rb_long2int(strlen(buf));
- return rb_exc_new(exc, buf, len);
+ if (NIL_P(str)) str = rb_str_new(0, 0);
+ return rb_exc_new3(exc, str);
}
void