diff options
author | Nick Mathewson <nickm@torproject.org> | 2018-09-18 15:18:52 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-10-14 15:25:16 -0400 |
commit | 7c8f20ba44a831ed9f714453fa776762d1c872c5 (patch) | |
tree | 0fac48c920e641a8271034575b1fda7774cda2fb /src/lib/tls | |
parent | dddecee291cadf391d93b569023f1f1e008880e8 (diff) | |
download | tor-7c8f20ba44a831ed9f714453fa776762d1c872c5.tar.gz tor-7c8f20ba44a831ed9f714453fa776762d1c872c5.zip |
In tor_tls_get_my_certs(), set cert ptrs even on failure
Nothing should ever look at them on failure, but in some cases,
the unit tests don't check for failure, and then GCC-LTO freaks out.
Fixes part of 27772.
Diffstat (limited to 'src/lib/tls')
-rw-r--r-- | src/lib/tls/tortls.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/lib/tls/tortls.c b/src/lib/tls/tortls.c index 3ae3a1a096..56f70bc371 100644 --- a/src/lib/tls/tortls.c +++ b/src/lib/tls/tortls.c @@ -71,13 +71,19 @@ tor_tls_get_my_certs(int server, const tor_x509_cert_t **id_cert_out) { tor_tls_context_t *ctx = tor_tls_context_get(server); - if (! ctx) - return -1; + int rv = -1; + const tor_x509_cert_t *link_cert = NULL; + const tor_x509_cert_t *id_cert = NULL; + if (ctx) { + rv = 0; + link_cert = server ? ctx->my_link_cert : ctx->my_auth_cert; + id_cert = ctx->my_id_cert; + } if (link_cert_out) - *link_cert_out = server ? ctx->my_link_cert : ctx->my_auth_cert; + *link_cert_out = link_cert; if (id_cert_out) - *id_cert_out = ctx->my_id_cert; - return 0; + *id_cert_out = id_cert; + return rv; } /** |