diff options
author | tb <> | 2023-03-06 14:32:06 +0000 |
---|---|---|
committer | tb <> | 2023-03-06 14:32:06 +0000 |
commit | 6c965e26b1a93da63948edae6b68564be1ded507 (patch) | |
tree | bbe07d6e06b695cebe22802551f2db0a61354d7c /src/usr.bin/openssl/sess_id.c | |
parent | 48e828ea26ee91710242131cd75cd9d1d20b773c (diff) | |
download | openbsd-6c965e26b1a93da63948edae6b68564be1ded507.tar.gz openbsd-6c965e26b1a93da63948edae6b68564be1ded507.tar.bz2 openbsd-6c965e26b1a93da63948edae6b68564be1ded507.zip |
Rename struct ${app}_config to plain cfg
All the structs are static and we need to reach into them many times.
Having a shorter name is more concise and results in less visual clutter.
It also avoids many overlong lines and we will be able to get rid of some
unfortunate line wrapping down the road.
Discussed with jsing
Diffstat (limited to 'src/usr.bin/openssl/sess_id.c')
-rw-r--r-- | src/usr.bin/openssl/sess_id.c | 58 |
1 files changed, 29 insertions, 29 deletions
diff --git a/src/usr.bin/openssl/sess_id.c b/src/usr.bin/openssl/sess_id.c index 4533cf15ca..c46da54244 100644 --- a/src/usr.bin/openssl/sess_id.c +++ b/src/usr.bin/openssl/sess_id.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sess_id.c,v 1.11 2022/11/11 17:07:39 joshua Exp $ */ | 1 | /* $OpenBSD: sess_id.c,v 1.12 2023/03/06 14:32:06 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 | * |
@@ -78,62 +78,62 @@ static struct { | |||
78 | char *outfile; | 78 | char *outfile; |
79 | int outformat; | 79 | int outformat; |
80 | int text; | 80 | int text; |
81 | } sess_id_config; | 81 | } cfg; |
82 | 82 | ||
83 | static const struct option sess_id_options[] = { | 83 | static const struct option sess_id_options[] = { |
84 | { | 84 | { |
85 | .name = "cert", | 85 | .name = "cert", |
86 | .desc = "Output certificate if present in session", | 86 | .desc = "Output certificate if present in session", |
87 | .type = OPTION_FLAG, | 87 | .type = OPTION_FLAG, |
88 | .opt.flag = &sess_id_config.cert, | 88 | .opt.flag = &cfg.cert, |
89 | }, | 89 | }, |
90 | { | 90 | { |
91 | .name = "context", | 91 | .name = "context", |
92 | .argname = "id", | 92 | .argname = "id", |
93 | .desc = "Set the session ID context for output", | 93 | .desc = "Set the session ID context for output", |
94 | .type = OPTION_ARG, | 94 | .type = OPTION_ARG, |
95 | .opt.arg = &sess_id_config.context, | 95 | .opt.arg = &cfg.context, |
96 | }, | 96 | }, |
97 | { | 97 | { |
98 | .name = "in", | 98 | .name = "in", |
99 | .argname = "file", | 99 | .argname = "file", |
100 | .desc = "Input file (default stdin)", | 100 | .desc = "Input file (default stdin)", |
101 | .type = OPTION_ARG, | 101 | .type = OPTION_ARG, |
102 | .opt.arg = &sess_id_config.infile, | 102 | .opt.arg = &cfg.infile, |
103 | }, | 103 | }, |
104 | { | 104 | { |
105 | .name = "inform", | 105 | .name = "inform", |
106 | .argname = "format", | 106 | .argname = "format", |
107 | .desc = "Input format (DER or PEM (default))", | 107 | .desc = "Input format (DER or PEM (default))", |
108 | .type = OPTION_ARG_FORMAT, | 108 | .type = OPTION_ARG_FORMAT, |
109 | .opt.value = &sess_id_config.informat, | 109 | .opt.value = &cfg.informat, |
110 | }, | 110 | }, |
111 | { | 111 | { |
112 | .name = "noout", | 112 | .name = "noout", |
113 | .desc = "Do not output the encoded session info", | 113 | .desc = "Do not output the encoded session info", |
114 | .type = OPTION_FLAG, | 114 | .type = OPTION_FLAG, |
115 | .opt.flag = &sess_id_config.noout, | 115 | .opt.flag = &cfg.noout, |
116 | }, | 116 | }, |
117 | { | 117 | { |
118 | .name = "out", | 118 | .name = "out", |
119 | .argname = "file", | 119 | .argname = "file", |
120 | .desc = "Output file (default stdout)", | 120 | .desc = "Output file (default stdout)", |
121 | .type = OPTION_ARG, | 121 | .type = OPTION_ARG, |
122 | .opt.arg = &sess_id_config.outfile, | 122 | .opt.arg = &cfg.outfile, |
123 | }, | 123 | }, |
124 | { | 124 | { |
125 | .name = "outform", | 125 | .name = "outform", |
126 | .argname = "format", | 126 | .argname = "format", |
127 | .desc = "Output format (DER or PEM (default))", | 127 | .desc = "Output format (DER or PEM (default))", |
128 | .type = OPTION_ARG_FORMAT, | 128 | .type = OPTION_ARG_FORMAT, |
129 | .opt.value = &sess_id_config.outformat, | 129 | .opt.value = &cfg.outformat, |
130 | }, | 130 | }, |
131 | { | 131 | { |
132 | .name = "text", | 132 | .name = "text", |
133 | .desc = "Print various public or private key components in" | 133 | .desc = "Print various public or private key components in" |
134 | " plain text", | 134 | " plain text", |
135 | .type = OPTION_FLAG, | 135 | .type = OPTION_FLAG, |
136 | .opt.flag = &sess_id_config.text, | 136 | .opt.flag = &cfg.text, |
137 | }, | 137 | }, |
138 | { NULL } | 138 | { NULL } |
139 | }; | 139 | }; |
@@ -163,62 +163,62 @@ sess_id_main(int argc, char **argv) | |||
163 | exit(1); | 163 | exit(1); |
164 | } | 164 | } |
165 | 165 | ||
166 | memset(&sess_id_config, 0, sizeof(sess_id_config)); | 166 | memset(&cfg, 0, sizeof(cfg)); |
167 | 167 | ||
168 | sess_id_config.informat = FORMAT_PEM; | 168 | cfg.informat = FORMAT_PEM; |
169 | sess_id_config.outformat = FORMAT_PEM; | 169 | cfg.outformat = FORMAT_PEM; |
170 | 170 | ||
171 | if (options_parse(argc, argv, sess_id_options, NULL, NULL) != 0) { | 171 | if (options_parse(argc, argv, sess_id_options, NULL, NULL) != 0) { |
172 | sess_id_usage(); | 172 | sess_id_usage(); |
173 | return (1); | 173 | return (1); |
174 | } | 174 | } |
175 | 175 | ||
176 | x = load_sess_id(sess_id_config.infile, sess_id_config.informat); | 176 | x = load_sess_id(cfg.infile, cfg.informat); |
177 | if (x == NULL) { | 177 | if (x == NULL) { |
178 | goto end; | 178 | goto end; |
179 | } | 179 | } |
180 | peer = SSL_SESSION_get0_peer(x); | 180 | peer = SSL_SESSION_get0_peer(x); |
181 | 181 | ||
182 | if (sess_id_config.context) { | 182 | if (cfg.context) { |
183 | size_t ctx_len = strlen(sess_id_config.context); | 183 | size_t ctx_len = strlen(cfg.context); |
184 | if (ctx_len > SSL_MAX_SID_CTX_LENGTH) { | 184 | if (ctx_len > SSL_MAX_SID_CTX_LENGTH) { |
185 | BIO_printf(bio_err, "Context too long\n"); | 185 | BIO_printf(bio_err, "Context too long\n"); |
186 | goto end; | 186 | goto end; |
187 | } | 187 | } |
188 | SSL_SESSION_set1_id_context(x, | 188 | SSL_SESSION_set1_id_context(x, |
189 | (unsigned char *)sess_id_config.context, ctx_len); | 189 | (unsigned char *)cfg.context, ctx_len); |
190 | } | 190 | } |
191 | 191 | ||
192 | if (!sess_id_config.noout || sess_id_config.text) { | 192 | if (!cfg.noout || cfg.text) { |
193 | out = BIO_new(BIO_s_file()); | 193 | out = BIO_new(BIO_s_file()); |
194 | if (out == NULL) { | 194 | if (out == NULL) { |
195 | ERR_print_errors(bio_err); | 195 | ERR_print_errors(bio_err); |
196 | goto end; | 196 | goto end; |
197 | } | 197 | } |
198 | if (sess_id_config.outfile == NULL) { | 198 | if (cfg.outfile == NULL) { |
199 | BIO_set_fp(out, stdout, BIO_NOCLOSE); | 199 | BIO_set_fp(out, stdout, BIO_NOCLOSE); |
200 | } else { | 200 | } else { |
201 | if (BIO_write_filename(out, sess_id_config.outfile) | 201 | if (BIO_write_filename(out, cfg.outfile) |
202 | <= 0) { | 202 | <= 0) { |
203 | perror(sess_id_config.outfile); | 203 | perror(cfg.outfile); |
204 | goto end; | 204 | goto end; |
205 | } | 205 | } |
206 | } | 206 | } |
207 | } | 207 | } |
208 | if (sess_id_config.text) { | 208 | if (cfg.text) { |
209 | SSL_SESSION_print(out, x); | 209 | SSL_SESSION_print(out, x); |
210 | 210 | ||
211 | if (sess_id_config.cert) { | 211 | if (cfg.cert) { |
212 | if (peer == NULL) | 212 | if (peer == NULL) |
213 | BIO_puts(out, "No certificate present\n"); | 213 | BIO_puts(out, "No certificate present\n"); |
214 | else | 214 | else |
215 | X509_print(out, peer); | 215 | X509_print(out, peer); |
216 | } | 216 | } |
217 | } | 217 | } |
218 | if (!sess_id_config.noout && !sess_id_config.cert) { | 218 | if (!cfg.noout && !cfg.cert) { |
219 | if (sess_id_config.outformat == FORMAT_ASN1) | 219 | if (cfg.outformat == FORMAT_ASN1) |
220 | i = i2d_SSL_SESSION_bio(out, x); | 220 | i = i2d_SSL_SESSION_bio(out, x); |
221 | else if (sess_id_config.outformat == FORMAT_PEM) | 221 | else if (cfg.outformat == FORMAT_PEM) |
222 | i = PEM_write_bio_SSL_SESSION(out, x); | 222 | i = PEM_write_bio_SSL_SESSION(out, x); |
223 | else { | 223 | else { |
224 | BIO_printf(bio_err, | 224 | BIO_printf(bio_err, |
@@ -229,11 +229,11 @@ sess_id_main(int argc, char **argv) | |||
229 | BIO_printf(bio_err, "unable to write SSL_SESSION\n"); | 229 | BIO_printf(bio_err, "unable to write SSL_SESSION\n"); |
230 | goto end; | 230 | goto end; |
231 | } | 231 | } |
232 | } else if (!sess_id_config.noout && (peer != NULL)) { | 232 | } else if (!cfg.noout && (peer != NULL)) { |
233 | /* just print the certificate */ | 233 | /* just print the certificate */ |
234 | if (sess_id_config.outformat == FORMAT_ASN1) | 234 | if (cfg.outformat == FORMAT_ASN1) |
235 | i = (int) i2d_X509_bio(out, peer); | 235 | i = (int) i2d_X509_bio(out, peer); |
236 | else if (sess_id_config.outformat == FORMAT_PEM) | 236 | else if (cfg.outformat == FORMAT_PEM) |
237 | i = PEM_write_bio_X509(out, peer); | 237 | i = PEM_write_bio_X509(out, peer); |
238 | else { | 238 | else { |
239 | BIO_printf(bio_err, | 239 | BIO_printf(bio_err, |