From cdf9d6f6ed992393e96d56cc5e9fa27ca329714e Mon Sep 17 00:00:00 2001 From: "Dr. Stephen Henson" Date: Sat, 11 Feb 2012 23:21:09 +0000 Subject: [PATCH] PR: 2716 Submitted by: Adam Langley Fix handling of exporter return value and use OpenSSL indentation in s_client, s_server. --- apps/s_client.c | 31 ++++++++++++++++-------------- apps/s_server.c | 51 ++++++++++++++++++++++++++----------------------- 2 files changed, 44 insertions(+), 38 deletions(-) diff --git a/apps/s_client.c b/apps/s_client.c index 22e6762838..20f661ec50 100644 --- a/apps/s_client.c +++ b/apps/s_client.c @@ -362,7 +362,7 @@ static void sc_usage(void) # endif #endif BIO_printf(bio_err," -legacy_renegotiation - enable use of legacy renegotiation (dangerous)\n"); - BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list"); + BIO_printf(bio_err," -use_srtp profiles - Offer SRTP key management with a colon-separated profile list\n"); BIO_printf(bio_err," -keymatexport label - Export keying material using label\n"); BIO_printf(bio_err," -keymatexportlen len - Export len bytes of keying material (default 20)\n"); } @@ -2077,30 +2077,33 @@ static void print_stuff(BIO *bio, SSL *s, int full) } SSL_SESSION_print(bio,SSL_get_session(s)); - if (keymatexportlabel != NULL) { + if (keymatexportlabel != NULL) + { BIO_printf(bio, "Keying material exporter:\n"); BIO_printf(bio, " Label: '%s'\n", keymatexportlabel); BIO_printf(bio, " Length: %i bytes\n", keymatexportlen); exportedkeymat = OPENSSL_malloc(keymatexportlen); - if (exportedkeymat != NULL) { - i = SSL_export_keying_material(s, exportedkeymat, - keymatexportlen, - keymatexportlabel, - strlen(keymatexportlabel), - NULL, 0, 0); - if (i != keymatexportlen) { - BIO_printf(bio, - " Error: return value %i\n", i); - } else { + if (exportedkeymat != NULL) + { + if (!SSL_export_keying_material(s, exportedkeymat, + keymatexportlen, + keymatexportlabel, + strlen(keymatexportlabel), + NULL, 0, 0)) + { + BIO_printf(bio, " Error\n"); + } + else + { BIO_printf(bio, " Keying material: "); for (i=0; i