mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/openssl/ossl_ssl_session.c (ossl_ssl_session_to_der):
OpenSSL::SSL::Session#to_der was broken. Fix buffer handling. * test/openssl/test_ssl_session.rb (test_session): Test it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32196 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
02ab6d95be
commit
bda678dc5b
3 changed files with 46 additions and 9 deletions
|
@ -195,20 +195,21 @@ static VALUE ossl_ssl_session_get_id(VALUE self)
|
|||
static VALUE ossl_ssl_session_to_der(VALUE self)
|
||||
{
|
||||
SSL_SESSION *ctx;
|
||||
unsigned char buf[1024*10], *p;
|
||||
unsigned char *p;
|
||||
int len;
|
||||
VALUE str;
|
||||
|
||||
GetSSLSession(self, ctx);
|
||||
|
||||
p = buf;
|
||||
len = i2d_SSL_SESSION(ctx, &p);
|
||||
|
||||
if (len <= 0)
|
||||
len = i2d_SSL_SESSION(ctx, NULL);
|
||||
if (len <= 0) {
|
||||
ossl_raise(eSSLSession, "i2d_SSL_SESSION");
|
||||
else if (len >= (int)sizeof(buf))
|
||||
ossl_raise(eSSLSession, "i2d_SSL_SESSION too large");
|
||||
}
|
||||
|
||||
return rb_str_new((const char *) p, len);
|
||||
str = rb_str_new(0, len);
|
||||
p = (unsigned char *)RSTRING_PTR(str);
|
||||
i2d_SSL_SESSION(ctx, &p);
|
||||
ossl_str_adjust(str, p);
|
||||
return str;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue