diff options
author | David Sommerseth <davids@redhat.com> | 2012-02-04 14:51:54 +0100 |
---|---|---|
committer | David Sommerseth <davids@redhat.com> | 2012-02-04 14:51:54 +0100 |
commit | 1951b415ed37187c26997f3fe1eb4c59e8dbf298 (patch) | |
tree | 80e5a078892d66607b467404bf87452fc4936a55 | |
parent | 5e86fd93779482b90a191f929edebe414cd78a4f (diff) | |
download | openvpn-1951b415ed37187c26997f3fe1eb4c59e8dbf298.tar.gz openvpn-1951b415ed37187c26997f3fe1eb4c59e8dbf298.tar.xz openvpn-1951b415ed37187c26997f3fe1eb4c59e8dbf298.zip |
Enhance the error handling in _openssl_get_subject()
Avoid an extra goto label and make the code a bit simpler.
Signed-off-by: David Sommerseth <davids@redhat.com>
Acked-by: Heiko Hund <heiko.hund@sophos.com>
Acked-by: Adriaan de Jong <dejong@fox-it.com>
-rw-r--r-- | ssl_verify_openssl.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/ssl_verify_openssl.c b/ssl_verify_openssl.c index e3f2d13..b2c01a3 100644 --- a/ssl_verify_openssl.c +++ b/ssl_verify_openssl.c @@ -249,21 +249,21 @@ x509_free_sha1_hash (unsigned char *hash) char * _openssl_get_subject (X509 *cert, char *buf, int size) { - BIO *subject_bio; + BIO *subject_bio = NULL; BUF_MEM *subject_mem; char *subject = buf; int maxlen = size; subject_bio = BIO_new (BIO_s_mem ()); if (subject_bio == NULL) - goto out; + goto err; X509_NAME_print_ex (subject_bio, X509_get_subject_name (cert), 0, XN_FLAG_SEP_CPLUS_SPC | XN_FLAG_FN_SN | ASN1_STRFLGS_UTF8_CONVERT | ASN1_STRFLGS_ESC_CTRL); if (BIO_eof (subject_bio)) - goto out_free; + goto err; BIO_get_mem_ptr (subject_bio, &subject_mem); if (subject == NULL) @@ -276,9 +276,10 @@ _openssl_get_subject (X509 *cert, char *buf, int size) memcpy (subject, subject_mem->data, maxlen); subject[maxlen - 1] = '\0'; -out_free: - BIO_free (subject_bio); -out: +err: + if (subject_bio) + BIO_free (subject_bio); + return subject; } |