diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-19 16:28:53 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-01-19 16:28:53 +0000 |
commit | 8302aa5f951e85984899d73fafa6bef2f23deddd (patch) | |
tree | e2d91c7eaadad662053210ef286ded8d89601f26 /ext/openssl | |
parent | b809254c8ce37ac996a7e0b2a9f27387cf7ee704 (diff) |
merge revision(s) 44569:44572,44576:44579,44581,44590:44594,44607,44608,44614,44615:
iseq.c: linear search
* iseq.c (iseq_type_from_id): linear search instead of hash lookup for
small fixed number keys.
------------------------------------------------------------------------
r44570 | nobu | 2014-01-12 17:11:32 +0900 (Sun, 12 Jan 2014) | 4 lines
tcltklib.c: create_ip_exc format argument
* ext/tk/tcltklib.c (create_ip_exc): format argument must not be a
dynamic string, not to contain unescaped %.
------------------------------------------------------------------------
r44571 | nobu | 2014-01-12 17:11:34 +0900 (Sun, 12 Jan 2014) | 5 lines
stubs.c: library name strings
* ext/tk/stubs.c (ruby_open_tcl_dll, ruby_open_tk_dll): make library
names by string literal concatenation at compilation time, not by
sprintf() at runtime.
------------------------------------------------------------------------
r44572 | nobu | 2014-01-12 17:11:36 +0900 (Sun, 12 Jan 2014) | 1 line
ext: use rb_sprintf() and rb_vsprintf() with PRIsVALUE
* ext/bigdecimal/bigdecimal.c (CLASS_NAME): macro to wrap
depending on PRIsVALUE for 1.9. [Backport #9406]
* ext/bigdecimal/bigdecimal.c (DECIMAL_SIZE_OF_BITS): fallback
definition for 2.1 or older. [ruby-core:59750] [Backport #9406]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_0_0@44659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/openssl')
-rw-r--r-- | ext/openssl/ossl.c | 18 | ||||
-rw-r--r-- | ext/openssl/ossl.h | 8 | ||||
-rw-r--r-- | ext/openssl/ossl_asn1.c | 4 | ||||
-rw-r--r-- | ext/openssl/ossl_cipher.c | 6 | ||||
-rw-r--r-- | ext/openssl/ossl_engine.c | 17 | ||||
-rw-r--r-- | ext/openssl/ossl_x509cert.c | 38 |
6 files changed, 34 insertions, 57 deletions
diff --git a/ext/openssl/ossl.c b/ext/openssl/ossl.c index 99307b4a75..1a6b71b477 100644 --- a/ext/openssl/ossl.c +++ b/ext/openssl/ossl.c @@ -293,10 +293,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(); @@ -304,14 +303,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){ @@ -320,8 +324,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 diff --git a/ext/openssl/ossl.h b/ext/openssl/ossl.h index 88e4506fa8..9a97656e9c 100644 --- a/ext/openssl/ossl.h +++ b/ext/openssl/ossl.h @@ -95,15 +95,15 @@ extern VALUE eOSSLError; */ #define OSSL_Check_Kind(obj, klass) do {\ if (!rb_obj_is_kind_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected kind of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected kind of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) #define OSSL_Check_Instance(obj, klass) do {\ if (!rb_obj_is_instance_of((obj), (klass))) {\ - ossl_raise(rb_eTypeError, "wrong argument (%s)! (Expected instance of %s)",\ - rb_obj_classname(obj), rb_class2name(klass));\ + ossl_raise(rb_eTypeError, "wrong argument (%"PRIsVALUE")! (Expected instance of %"PRIsVALUE")",\ + rb_obj_class(obj), (klass));\ }\ } while (0) diff --git a/ext/openssl/ossl_asn1.c b/ext/openssl/ossl_asn1.c index 6b4d523ee3..e66abe85a9 100644 --- a/ext/openssl/ossl_asn1.c +++ b/ext/openssl/ossl_asn1.c @@ -624,8 +624,8 @@ ossl_asn1_default_tag(VALUE obj) } tmp_class = rb_class_superclass(tmp_class); } - ossl_raise(eASN1Error, "universal tag for %s not found", - rb_class2name(CLASS_OF(obj))); + ossl_raise(eASN1Error, "universal tag for %"PRIsVALUE" not found", + rb_obj_class(obj)); return -1; /* dummy */ } diff --git a/ext/openssl/ossl_cipher.c b/ext/openssl/ossl_cipher.c index 03374372ad..df6fd10887 100644 --- a/ext/openssl/ossl_cipher.c +++ b/ext/openssl/ossl_cipher.c @@ -213,9 +213,9 @@ ossl_cipher_init(int argc, VALUE *argv, VALUE self, int mode) * We deprecated the arguments for this method, but we decided * keeping this behaviour for backward compatibility. */ - const char *cname = rb_class2name(rb_obj_class(self)); - rb_warn("arguments for %s#encrypt and %s#decrypt were deprecated; " - "use %s#pkcs5_keyivgen to derive key and IV", + VALUE cname = rb_class_path(rb_obj_class(self)); + rb_warn("arguments for %"PRIsVALUE"#encrypt and %"PRIsVALUE"#decrypt were deprecated; " + "use %"PRIsVALUE"#pkcs5_keyivgen to derive key and IV", cname, cname, cname); StringValue(pass); GetCipher(self, ctx); diff --git a/ext/openssl/ossl_engine.c b/ext/openssl/ossl_engine.c index f85454108a..6c6c80886e 100644 --- a/ext/openssl/ossl_engine.c +++ b/ext/openssl/ossl_engine.c @@ -365,18 +365,11 @@ ossl_engine_get_cmds(VALUE self) static VALUE ossl_engine_inspect(VALUE self) { - VALUE str; - const char *cname = rb_class2name(rb_obj_class(self)); - - str = rb_str_new2("#<"); - rb_str_cat2(str, cname); - rb_str_cat2(str, " id=\""); - rb_str_append(str, ossl_engine_get_id(self)); - rb_str_cat2(str, "\" name=\""); - rb_str_append(str, ossl_engine_get_name(self)); - rb_str_cat2(str, "\">"); - - return str; + ENGINE *e; + + GetEngine(self, e); + return rb_sprintf("#<%"PRIsVALUE" id=\"%s\" name=\"%s\">", + rb_obj_class(self), ENGINE_get_id(e), ENGINE_get_name(e)); } #define DefEngineConst(x) rb_define_const(cEngine, #x, INT2NUM(ENGINE_##x)) diff --git a/ext/openssl/ossl_x509cert.c b/ext/openssl/ossl_x509cert.c index 84cedc763a..85bbc0d081 100644 --- a/ext/openssl/ossl_x509cert.c +++ b/ext/openssl/ossl_x509cert.c @@ -693,35 +693,15 @@ ossl_x509_add_extension(VALUE self, VALUE extension) static VALUE ossl_x509_inspect(VALUE self) { - VALUE str; - const char *cname = rb_class2name(rb_obj_class(self)); - - str = rb_str_new2("#<"); - rb_str_cat2(str, cname); - rb_str_cat2(str, " "); - - rb_str_cat2(str, "subject="); - rb_str_append(str, rb_inspect(ossl_x509_get_subject(self))); - rb_str_cat2(str, ", "); - - rb_str_cat2(str, "issuer="); - rb_str_append(str, rb_inspect(ossl_x509_get_issuer(self))); - rb_str_cat2(str, ", "); - - rb_str_cat2(str, "serial="); - rb_str_append(str, rb_inspect(ossl_x509_get_serial(self))); - rb_str_cat2(str, ", "); - - rb_str_cat2(str, "not_before="); - rb_str_append(str, rb_inspect(ossl_x509_get_not_before(self))); - rb_str_cat2(str, ", "); - - rb_str_cat2(str, "not_after="); - rb_str_append(str, rb_inspect(ossl_x509_get_not_after(self))); - - str = rb_str_cat2(str, ">"); - - return str; + return rb_sprintf("#<%"PRIsVALUE": subject=%+"PRIsVALUE", " + "issuer=%+"PRIsVALUE", serial=%+"PRIsVALUE", " + "not_before=%+"PRIsVALUE", not_after=%+"PRIsVALUE">", + rb_obj_class(self), + ossl_x509_get_subject(self), + ossl_x509_get_issuer(self), + ossl_x509_get_serial(self), + ossl_x509_get_not_before(self), + ossl_x509_get_not_after(self)); } /* |