[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
@ -265,20 +265,14 @@ ossl_to_der_if_possible(VALUE obj)
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
PRINTF_ARGS(static VALUE ossl_make_error(VALUE exc, const char *fmt, va_list args), 2, 0);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Errors
|
* Errors
|
||||||
*/
|
*/
|
||||||
static VALUE
|
VALUE
|
||||||
ossl_make_error(VALUE exc, const char *fmt, va_list args)
|
ossl_make_error(VALUE exc, VALUE str)
|
||||||
{
|
{
|
||||||
VALUE str = Qnil;
|
|
||||||
unsigned long e;
|
unsigned long e;
|
||||||
|
|
||||||
if (fmt) {
|
|
||||||
str = rb_vsprintf(fmt, args);
|
|
||||||
}
|
|
||||||
e = ERR_peek_last_error();
|
e = ERR_peek_last_error();
|
||||||
if (e) {
|
if (e) {
|
||||||
const char *msg = ERR_reason_error_string(e);
|
const char *msg = ERR_reason_error_string(e);
|
||||||
@ -302,10 +296,17 @@ ossl_raise(VALUE exc, const char *fmt, ...)
|
|||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
VALUE err;
|
VALUE err;
|
||||||
va_start(args, fmt);
|
|
||||||
err = ossl_make_error(exc, fmt, args);
|
if (fmt) {
|
||||||
va_end(args);
|
va_start(args, fmt);
|
||||||
rb_exc_raise(err);
|
err = rb_vsprintf(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
err = Qnil;
|
||||||
|
}
|
||||||
|
|
||||||
|
rb_exc_raise(ossl_make_error(exc, err));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -121,6 +121,8 @@ int ossl_pem_passwd_cb(char *, int, int, void *);
|
|||||||
* ERRor messages
|
* ERRor messages
|
||||||
*/
|
*/
|
||||||
PRINTF_ARGS(NORETURN(void ossl_raise(VALUE, const char *, ...)), 2, 3);
|
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. */
|
/* Clear OpenSSL error queue. If dOSSL is set, rb_warn() them. */
|
||||||
void ossl_clear_error(void);
|
void ossl_clear_error(void);
|
||||||
|
|
||||||
|
@ -1223,7 +1223,7 @@ end:
|
|||||||
ASN1_OBJECT_free(def_policy_id_obj);
|
ASN1_OBJECT_free(def_policy_id_obj);
|
||||||
TS_RESP_CTX_free(ctx);
|
TS_RESP_CTX_free(ctx);
|
||||||
if (err_msg)
|
if (err_msg)
|
||||||
ossl_raise(eTimestampError, err_msg);
|
rb_exc_raise(ossl_make_error(eTimestampError, rb_str_new_cstr(err_msg)));
|
||||||
if (status)
|
if (status)
|
||||||
rb_jump_tag(status);
|
rb_jump_tag(status);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user