diff options
author | Ziga Seilnacht <ziga.seilnacht@gmail.com> | 2009-12-22 16:54:20 +0100 |
---|---|---|
committer | Jean-Paul Calderone <exarkun@divmod.com> | 2009-12-22 16:54:20 +0100 |
commit | cd48be9bac3a3e66a53b1942477db03dc5b49ad3 (patch) | |
tree | 221bac740250107fe019192ece17e9d45112312d /OpenSSL/crypto | |
parent | 376cf9796ec555bc0baa599ed9aba0c4959d4127 (diff) | |
download | pyopenssl-cd48be9bac3a3e66a53b1942477db03dc5b49ad3.tar.gz |
Add a few more error checks around OpenSSL API calls.
These errors can only occur in low memory conditions, so there
is no reasonable way to test them.
Diffstat (limited to 'OpenSSL/crypto')
-rw-r--r-- | OpenSSL/crypto/crypto.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/OpenSSL/crypto/crypto.c b/OpenSSL/crypto/crypto.c index b0e0d2f..d642dc6 100644 --- a/OpenSSL/crypto/crypto.c +++ b/OpenSSL/crypto/crypto.c @@ -143,6 +143,10 @@ crypto_load_privatekey(PyObject *spam, PyObject *args) } bio = BIO_new_mem_buf(buffer, len); + if (bio == NULL) { + exception_from_error_queue(crypto_Error); + return NULL; + } switch (type) { case X509_FILETYPE_PEM: @@ -220,6 +224,10 @@ crypto_dump_privatekey(PyObject *spam, PyObject *args) } bio = BIO_new(BIO_s_mem()); + if (bio == NULL) { + exception_from_error_queue(crypto_Error); + return NULL; + } switch (type) { case X509_FILETYPE_PEM: @@ -232,6 +240,10 @@ crypto_dump_privatekey(PyObject *spam, PyObject *args) case X509_FILETYPE_TEXT: rsa = EVP_PKEY_get1_RSA(pkey->pkey); + if (rsa == NULL) { + ret = 0; + break; + } ret = RSA_print(bio, rsa, 0); RSA_free(rsa); break; |