mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
[ruby/openssl] Separate formatting from ossl_make_error
Just append OpenSSL error reason to the given message string object, which would be alreadly formatted. Suppress -Wformat-security warning in `ossl_tsfac_create_ts`. https://github.com/ruby/openssl/commit/11b1d8a6b8
This commit is contained in:
parent
c7dce12eb9
commit
598d66f6b2
3 changed files with 16 additions and 13 deletions
|
@ -265,20 +265,14 @@ ossl_to_der_if_possible(VALUE obj)
|
|||
return obj;
|
||||
}
|
||||
|
||||
PRINTF_ARGS(static VALUE ossl_make_error(VALUE exc, const char *fmt, va_list args), 2, 0);
|
||||
|
||||
/*
|
||||
* Errors
|
||||
*/
|
||||
static VALUE
|
||||
ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
||||
VALUE
|
||||
ossl_make_error(VALUE exc, VALUE str)
|
||||
{
|
||||
VALUE str = Qnil;
|
||||
unsigned long e;
|
||||
|
||||
if (fmt) {
|
||||
str = rb_vsprintf(fmt, args);
|
||||
}
|
||||
e = ERR_peek_last_error();
|
||||
if (e) {
|
||||
const char *msg = ERR_reason_error_string(e);
|
||||
|
@ -302,10 +296,17 @@ ossl_raise(VALUE exc, const char *fmt, ...)
|
|||
{
|
||||
va_list args;
|
||||
VALUE err;
|
||||
va_start(args, fmt);
|
||||
err = ossl_make_error(exc, fmt, args);
|
||||
va_end(args);
|
||||
rb_exc_raise(err);
|
||||
|
||||
if (fmt) {
|
||||
va_start(args, fmt);
|
||||
err = rb_vsprintf(fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
else {
|
||||
err = Qnil;
|
||||
}
|
||||
|
||||
rb_exc_raise(ossl_make_error(exc, err));
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
@ -121,6 +121,8 @@ int ossl_pem_passwd_cb(char *, int, int, void *);
|
|||
* ERRor messages
|
||||
*/
|
||||
PRINTF_ARGS(NORETURN(void ossl_raise(VALUE, const char *, ...)), 2, 3);
|
||||
/* Make exception instance from str and OpenSSL error reason string. */
|
||||
VALUE ossl_make_error(VALUE exc, VALUE str);
|
||||
/* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
|
||||
void ossl_clear_error(void);
|
||||
|
||||
|
|
|
@ -1223,7 +1223,7 @@ end:
|
|||
ASN1_OBJECT_free(def_policy_id_obj);
|
||||
TS_RESP_CTX_free(ctx);
|
||||
if (err_msg)
|
||||
ossl_raise(eTimestampError, err_msg);
|
||||
rb_exc_raise(ossl_make_error(eTimestampError, rb_str_new_cstr(err_msg)));
|
||||
if (status)
|
||||
rb_jump_tag(status);
|
||||
return ret;
|
||||
|
|
Loading…
Reference in a new issue