1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/ext/openssl/ossl_bio.c
nagachika f012932218 merge revision(s) 59567: [Backport #13796]
openssl: import v2.0.5

	Import Ruby/OpenSSL 2.0.5. The full commit history since v2.0.4
	(imported at r59081) can be found at:

		https://github.com/ruby/openssl/compare/v2.0.4...v2.0.5

	This will fix the test failure on latest Debian sid and the "no
	OPENSSL_Applink" issue on mswin.

	----------------------------------------------------------------
	Kazuki Yamaguchi (11):
	      test/test_ssl: allow 3DES cipher suites in test_sslctx_set_params
	      bio: prevent possible GC issue in ossl_obj2bio()
	      bio: do not use the FILE BIO method in ossl_obj2bio()
	      Rakefile: install_dependencies: install only when needed
	      appveyor.yml: test against Ruby 2.4
	      ossl_pem_passwd_cb: relax passphrase length constraint
	      ossl_pem_passwd_cb: do not check for taintedness
	      ossl_pem_passwd_cb: handle nil from the block explicitly
	      ssl: remove unsupported TLS versions from SSLContext::METHODS
	      ssl: fix compile error with OpenSSL 1.0.0
	      Ruby/OpenSSL 2.0.5

	Lars Kanis (1):
	      Add msys2 library dependency tag in gem metadata

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_4@59784 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-09-08 14:38:12 +00:00

57 lines
1 KiB
C

/*
* 'OpenSSL for Ruby' team members
* Copyright (C) 2003
* All rights reserved.
*/
/*
* This program is licensed under the same licence as Ruby.
* (See the file 'LICENCE'.)
*/
#include "ossl.h"
BIO *
ossl_obj2bio(volatile VALUE *pobj)
{
VALUE obj = *pobj;
BIO *bio;
if (RB_TYPE_P(obj, T_FILE))
obj = rb_funcallv(obj, rb_intern("read"), 0, NULL);
StringValue(obj);
bio = BIO_new_mem_buf(RSTRING_PTR(obj), RSTRING_LENINT(obj));
if (!bio)
ossl_raise(eOSSLError, "BIO_new_mem_buf");
*pobj = obj;
return bio;
}
VALUE
ossl_membio2str0(BIO *bio)
{
VALUE ret;
BUF_MEM *buf;
BIO_get_mem_ptr(bio, &buf);
ret = rb_str_new(buf->data, buf->length);
return ret;
}
VALUE
ossl_protect_membio2str(BIO *bio, int *status)
{
return rb_protect((VALUE (*)(VALUE))ossl_membio2str0, (VALUE)bio, status);
}
VALUE
ossl_membio2str(BIO *bio)
{
VALUE ret;
int status = 0;
ret = ossl_protect_membio2str(bio, &status);
BIO_free(bio);
if(status) rb_jump_tag(status);
return ret;
}