Mercurial > dovecot > core-2.2
changeset 20400:525fbfacf07d
lib-dcrypt: Don't ignore BIO errors.
Might happen due to out of memory?
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Sun, 19 Jun 2016 22:18:04 +0300 |
parents | 0798860710f7 |
children | e4b4aa1af043 |
files | src/lib-dcrypt/dcrypt-openssl.c |
diffstat | 1 files changed, 7 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib-dcrypt/dcrypt-openssl.c Sun Jun 19 21:21:56 2016 +0300 +++ b/src/lib-dcrypt/dcrypt-openssl.c Sun Jun 19 22:18:04 2016 +0300 @@ -1506,7 +1506,7 @@ BIO *key_in = BIO_new_mem_buf((void*)data, strlen(data)); key = PEM_read_bio_PUBKEY(key_in, &key, NULL, NULL); - (void)BIO_reset(key_in); + if (BIO_reset(key_in) <= 0) i_unreached(); if (key == NULL) { /* ec keys are bother */ /* read the header */ char buf[27]; /* begin public key */ @@ -1565,7 +1565,8 @@ ec = PEM_write_bio_PrivateKey(key_out, pkey, algo, NULL, 0, NULL, (void*)password); - (void)BIO_flush(key_out); + if (BIO_flush(key_out) <= 0) + ec = -1; if (ec != 1) { BIO_vfree(key_out); @@ -1598,10 +1599,12 @@ (void)BIO_puts(key_out, "-----BEGIN PUBLIC KEY-----\n"); (void)BIO_push(b64, key_out); ec = i2d_EC_PUBKEY_bio(b64, EVP_PKEY_get0_EC_KEY(pkey)); - (void)BIO_flush(b64); + if (BIO_flush(b64) <= 0) + ec = -1; (void)BIO_pop(b64); BIO_vfree(b64); - (void)BIO_puts(key_out, "-----END PUBLIC KEY-----"); + if (BIO_puts(key_out, "-----END PUBLIC KEY-----") <= 0) + ec = -1; } if (ec != 1) {