Skip to content

Commit

Permalink
ossl_obj2bio does not return NULL.
Browse files Browse the repository at this point in the history
  • Loading branch information
ioquatix committed May 19, 2021
1 parent 7ad5653 commit 61b4355
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
20 changes: 12 additions & 8 deletions ext/openssl/ossl_bio.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,31 @@ ossl_obj2bio(volatile VALUE *pobj)
BIO *bio;

if (RB_TYPE_P(obj, T_FILE))
obj = rb_funcallv(obj, rb_intern("read"), 0, NULL);
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");
ossl_raise(eOSSLError, "BIO_new_mem_buf");

*pobj = obj;
return bio;
}

VALUE
ossl_membio2str(BIO *bio)
{
VALUE ret;
VALUE result;
int state;
BUF_MEM *buf;
BUF_MEM *memory_buffer;

BIO_get_mem_ptr(bio, &buf);
ret = ossl_str_new(buf->data, buf->length, &state);
BIO_get_mem_ptr(bio, &memory_buffer);
result = ossl_str_new(memory_buffer->data, memory_buffer->length, &state);
BIO_free(bio);

if (state)
rb_jump_tag(state);
rb_jump_tag(state);

return ret;
return result;
}
3 changes: 0 additions & 3 deletions ext/openssl/ossl_x509cert.c
Original file line number Diff line number Diff line change
Expand Up @@ -887,9 +887,6 @@ ossl_x509_load(VALUE klass, VALUE buffer)
{
BIO *in = ossl_obj2bio(&buffer);

if (in == NULL)
ossl_raise(eX509CertError, NULL);

return rb_ensure(load_chained_certificates, (VALUE)in, load_chained_certificates_ensure, (VALUE)in);
}

Expand Down

0 comments on commit 61b4355

Please sign in to comment.