From d504e61a409f63f8ce6c117fe828cd0babb37589 Mon Sep 17 00:00:00 2001 From: inoguchi <> Date: Fri, 10 Jul 2020 12:25:57 +0000 Subject: Clean up s_client.c - Remove space between '*' and pointer variable. - Add function prototype. - Move callback function to bottom. - Move typedef struct to up. --- src/usr.bin/openssl/s_client.c | 53 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 26 deletions(-) (limited to 'src') diff --git a/src/usr.bin/openssl/s_client.c b/src/usr.bin/openssl/s_client.c index 54fcc75bb4..614effe960 100644 --- a/src/usr.bin/openssl/s_client.c +++ b/src/usr.bin/openssl/s_client.c @@ -1,4 +1,4 @@ -/* $OpenBSD: s_client.c,v 1.50 2020/07/10 12:05:52 inoguchi Exp $ */ +/* $OpenBSD: s_client.c,v 1.51 2020/07/10 12:25:57 inoguchi Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -171,8 +171,9 @@ #define BUFSIZZ 1024*8 static void sc_usage(void); -static void print_stuff(BIO * berr, SSL * con, int full); -static int ocsp_resp_cb(SSL * s, void *arg); +static void print_stuff(BIO *berr, SSL *con, int full); +static int ocsp_resp_cb(SSL *s, void *arg); +static int ssl_servername_cb(SSL *s, int *ad, void *arg); enum { PROTO_OFF = 0, @@ -184,6 +185,12 @@ enum { PROTO_XMPP, }; +/* This is a context that we pass to callbacks */ +typedef struct tlsextctx_st { + BIO *biodebug; + int ack; +} tlsextctx; + static struct { int af; char *alpn_in; @@ -839,25 +846,6 @@ sc_usage(void) fprintf(stderr, "\n"); } -/* This is a context that we pass to callbacks */ -typedef struct tlsextctx_st { - BIO *biodebug; - int ack; -} tlsextctx; - -static int -ssl_servername_cb(SSL * s, int *ad, void *arg) -{ - tlsextctx *p = (tlsextctx *) arg; - const char *hn = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); - if (SSL_get_servername_type(s) != -1) - p->ack = !SSL_session_reused(s) && hn != NULL; - else - BIO_printf(bio_err, "Can't use SSL_get_servername\n"); - - return SSL_TLSEXT_ERR_OK; -} - int s_client_main(int argc, char **argv) { @@ -1626,14 +1614,14 @@ s_client_main(int argc, char **argv) } static void -print_stuff(BIO * bio, SSL * s, int full) +print_stuff(BIO *bio, SSL *s, int full) { X509 *peer = NULL; char *p; static const char *space = " "; char buf[BUFSIZ]; - STACK_OF(X509) * sk; - STACK_OF(X509_NAME) * sk2; + STACK_OF(X509) *sk; + STACK_OF(X509_NAME) *sk2; const SSL_CIPHER *c; X509_NAME *xn; int j, i; @@ -1814,7 +1802,7 @@ print_stuff(BIO * bio, SSL * s, int full) } static int -ocsp_resp_cb(SSL * s, void *arg) +ocsp_resp_cb(SSL *s, void *arg) { const unsigned char *p; int len; @@ -1838,3 +1826,16 @@ ocsp_resp_cb(SSL * s, void *arg) return 1; } +static int +ssl_servername_cb(SSL *s, int *ad, void *arg) +{ + tlsextctx *p = (tlsextctx *) arg; + const char *hn = SSL_get_servername(s, TLSEXT_NAMETYPE_host_name); + if (SSL_get_servername_type(s) != -1) + p->ack = !SSL_session_reused(s) && hn != NULL; + else + BIO_printf(bio_err, "Can't use SSL_get_servername\n"); + + return SSL_TLSEXT_ERR_OK; +} + -- cgit v1.2.3-55-g6feb