diff options
author | tb <> | 2022-06-06 15:20:54 +0000 |
---|---|---|
committer | tb <> | 2022-06-06 15:20:54 +0000 |
commit | a5111001f9bfe0d0764d8490825d5f6651b92039 (patch) | |
tree | 04ccfa66692abbb6c98308a65bf2a0d0a64fb0c9 | |
parent | c1f20825c8c5e07b149b951b1fbf31539b4a1bb9 (diff) | |
download | openbsd-a5111001f9bfe0d0764d8490825d5f6651b92039.tar.gz openbsd-a5111001f9bfe0d0764d8490825d5f6651b92039.tar.bz2 openbsd-a5111001f9bfe0d0764d8490825d5f6651b92039.zip |
Minor style cleanup in ssl_txt.c
Wrap long lines and fix a bug where the wrong struct member was checked
for NULL.
ok jsing
-rw-r--r-- | src/lib/libssl/ssl_txt.c | 64 |
1 files changed, 41 insertions, 23 deletions
diff --git a/src/lib/libssl/ssl_txt.c b/src/lib/libssl/ssl_txt.c index 72ce1a0bce..0968543619 100644 --- a/src/lib/libssl/ssl_txt.c +++ b/src/lib/libssl/ssl_txt.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssl_txt.c,v 1.31 2021/11/29 18:36:27 tb Exp $ */ | 1 | /* $OpenBSD: ssl_txt.c,v 1.32 2022/06/06 15:20:54 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -96,92 +96,110 @@ SSL_SESSION_print_fp(FILE *fp, const SSL_SESSION *x) | |||
96 | 96 | ||
97 | if ((b = BIO_new(BIO_s_file())) == NULL) { | 97 | if ((b = BIO_new(BIO_s_file())) == NULL) { |
98 | SSLerrorx(ERR_R_BUF_LIB); | 98 | SSLerrorx(ERR_R_BUF_LIB); |
99 | return (0); | 99 | return 0; |
100 | } | 100 | } |
101 | BIO_set_fp(b, fp, BIO_NOCLOSE); | 101 | BIO_set_fp(b, fp, BIO_NOCLOSE); |
102 | ret = SSL_SESSION_print(b, x); | 102 | ret = SSL_SESSION_print(b, x); |
103 | BIO_free(b); | 103 | BIO_free(b); |
104 | return (ret); | 104 | return ret; |
105 | } | 105 | } |
106 | 106 | ||
107 | int | 107 | int |
108 | SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) | 108 | SSL_SESSION_print(BIO *bp, const SSL_SESSION *x) |
109 | { | 109 | { |
110 | unsigned int i; | 110 | unsigned int i; |
111 | const char *s; | 111 | int ret = 0; |
112 | 112 | ||
113 | if (x == NULL) | 113 | if (x == NULL) |
114 | goto err; | 114 | goto err; |
115 | |||
115 | if (BIO_puts(bp, "SSL-Session:\n") <= 0) | 116 | if (BIO_puts(bp, "SSL-Session:\n") <= 0) |
116 | goto err; | 117 | goto err; |
117 | 118 | ||
118 | s = ssl_version_string(x->ssl_version); | 119 | if (BIO_printf(bp, " Protocol : %s\n", |
119 | if (BIO_printf(bp, " Protocol : %s\n", s) <= 0) | 120 | ssl_version_string(x->ssl_version)) <= 0) |
120 | goto err; | 121 | goto err; |
121 | 122 | ||
122 | if (x->cipher == NULL) { | 123 | if (x->cipher == NULL) { |
123 | if (((x->cipher_id) & 0xff000000) == 0x02000000) { | 124 | if ((x->cipher_id & 0xff000000) == 0x02000000) { |
124 | if (BIO_printf(bp, " Cipher : %06lX\n", x->cipher_id&0xffffff) <= 0) | 125 | if (BIO_printf(bp, " Cipher : %06lX\n", |
126 | x->cipher_id & 0xffffff) <= 0) | ||
125 | goto err; | 127 | goto err; |
126 | } else { | 128 | } else { |
127 | if (BIO_printf(bp, " Cipher : %04lX\n", x->cipher_id&0xffff) <= 0) | 129 | if (BIO_printf(bp, " Cipher : %04lX\n", |
130 | x->cipher_id & 0xffff) <= 0) | ||
128 | goto err; | 131 | goto err; |
129 | } | 132 | } |
130 | } else { | 133 | } else { |
131 | if (BIO_printf(bp, " Cipher : %s\n",((x->cipher == NULL)?"unknown":x->cipher->name)) <= 0) | 134 | const char *cipher_name = "unknown"; |
135 | |||
136 | if (x->cipher->name != NULL) | ||
137 | cipher_name = x->cipher->name; | ||
138 | |||
139 | if (BIO_printf(bp, " Cipher : %s\n", cipher_name) <= 0) | ||
132 | goto err; | 140 | goto err; |
133 | } | 141 | } |
142 | |||
134 | if (BIO_puts(bp, " Session-ID: ") <= 0) | 143 | if (BIO_puts(bp, " Session-ID: ") <= 0) |
135 | goto err; | 144 | goto err; |
145 | |||
136 | for (i = 0; i < x->session_id_length; i++) { | 146 | for (i = 0; i < x->session_id_length; i++) { |
137 | if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0) | 147 | if (BIO_printf(bp, "%02X", x->session_id[i]) <= 0) |
138 | goto err; | 148 | goto err; |
139 | } | 149 | } |
150 | |||
140 | if (BIO_puts(bp, "\n Session-ID-ctx: ") <= 0) | 151 | if (BIO_puts(bp, "\n Session-ID-ctx: ") <= 0) |
141 | goto err; | 152 | goto err; |
153 | |||
142 | for (i = 0; i < x->sid_ctx_length; i++) { | 154 | for (i = 0; i < x->sid_ctx_length; i++) { |
143 | if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0) | 155 | if (BIO_printf(bp, "%02X", x->sid_ctx[i]) <= 0) |
144 | goto err; | 156 | goto err; |
145 | } | 157 | } |
158 | |||
146 | if (BIO_puts(bp, "\n Master-Key: ") <= 0) | 159 | if (BIO_puts(bp, "\n Master-Key: ") <= 0) |
147 | goto err; | 160 | goto err; |
161 | |||
148 | for (i = 0; i < (unsigned int)x->master_key_length; i++) { | 162 | for (i = 0; i < (unsigned int)x->master_key_length; i++) { |
149 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) | 163 | if (BIO_printf(bp, "%02X", x->master_key[i]) <= 0) |
150 | goto err; | 164 | goto err; |
151 | } | 165 | } |
152 | if (x->tlsext_tick_lifetime_hint) { | 166 | |
167 | if (x->tlsext_tick_lifetime_hint > 0) { | ||
153 | if (BIO_printf(bp, | 168 | if (BIO_printf(bp, |
154 | "\n TLS session ticket lifetime hint: %u (seconds)", | 169 | "\n TLS session ticket lifetime hint: %u (seconds)", |
155 | x->tlsext_tick_lifetime_hint) <= 0) | 170 | x->tlsext_tick_lifetime_hint) <= 0) |
156 | goto err; | 171 | goto err; |
157 | } | 172 | } |
158 | if (x->tlsext_tick) { | 173 | |
174 | if (x->tlsext_tick != NULL) { | ||
159 | if (BIO_puts(bp, "\n TLS session ticket:\n") <= 0) | 175 | if (BIO_puts(bp, "\n TLS session ticket:\n") <= 0) |
160 | goto err; | 176 | goto err; |
161 | if (BIO_dump_indent(bp, (char *)x->tlsext_tick, x->tlsext_ticklen, 4) <= 0) | 177 | if (BIO_dump_indent(bp, x->tlsext_tick, x->tlsext_ticklen, |
178 | 4) <= 0) | ||
162 | goto err; | 179 | goto err; |
163 | } | 180 | } |
164 | 181 | ||
165 | if (x->time != 0) { | 182 | if (x->time != 0) { |
166 | if (BIO_printf(bp, "\n Start Time: %lld", (long long)x->time) <= 0) | 183 | if (BIO_printf(bp, "\n Start Time: %lld", |
184 | (long long)x->time) <= 0) | ||
167 | goto err; | 185 | goto err; |
168 | } | 186 | } |
169 | if (x->timeout != 0L) { | 187 | |
170 | if (BIO_printf(bp, "\n Timeout : %ld (sec)", x->timeout) <= 0) | 188 | if (x->timeout != 0) { |
189 | if (BIO_printf(bp, "\n Timeout : %ld (sec)", | ||
190 | x->timeout) <= 0) | ||
171 | goto err; | 191 | goto err; |
172 | } | 192 | } |
173 | if (BIO_puts(bp, "\n") <= 0) | ||
174 | goto err; | ||
175 | 193 | ||
176 | if (BIO_puts(bp, " Verify return code: ") <= 0) | 194 | if (BIO_puts(bp, "\n") <= 0) |
177 | goto err; | 195 | goto err; |
178 | 196 | ||
179 | if (BIO_printf(bp, "%ld (%s)\n", x->verify_result, | 197 | if (BIO_printf(bp, " Verify return code: %ld (%s)\n", |
198 | x->verify_result, | ||
180 | X509_verify_cert_error_string(x->verify_result)) <= 0) | 199 | X509_verify_cert_error_string(x->verify_result)) <= 0) |
181 | goto err; | 200 | goto err; |
182 | 201 | ||
183 | return (1); | 202 | ret = 1; |
184 | err: | 203 | err: |
185 | return (0); | 204 | return ret; |
186 | } | 205 | } |
187 | |||