diff options
Diffstat (limited to 'src/usr.bin/openssl/nseq.c')
-rw-r--r-- | src/usr.bin/openssl/nseq.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/usr.bin/openssl/nseq.c b/src/usr.bin/openssl/nseq.c index 7be116e67b..fb0dda5dca 100644 --- a/src/usr.bin/openssl/nseq.c +++ b/src/usr.bin/openssl/nseq.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: nseq.c,v 1.10 2022/11/11 17:07:39 joshua Exp $ */ | 1 | /* $OpenBSD: nseq.c,v 1.11 2023/03/06 14:32:06 tb Exp $ */ |
2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
3 | * project 1999. | 3 | * project 1999. |
4 | */ | 4 | */ |
@@ -68,7 +68,7 @@ static struct { | |||
68 | char *infile; | 68 | char *infile; |
69 | char *outfile; | 69 | char *outfile; |
70 | int toseq; | 70 | int toseq; |
71 | } nseq_config; | 71 | } cfg; |
72 | 72 | ||
73 | static const struct option nseq_options[] = { | 73 | static const struct option nseq_options[] = { |
74 | { | 74 | { |
@@ -76,20 +76,20 @@ static const struct option nseq_options[] = { | |||
76 | .argname = "file", | 76 | .argname = "file", |
77 | .desc = "Input file to read from (default stdin)", | 77 | .desc = "Input file to read from (default stdin)", |
78 | .type = OPTION_ARG, | 78 | .type = OPTION_ARG, |
79 | .opt.arg = &nseq_config.infile, | 79 | .opt.arg = &cfg.infile, |
80 | }, | 80 | }, |
81 | { | 81 | { |
82 | .name = "out", | 82 | .name = "out", |
83 | .argname = "file", | 83 | .argname = "file", |
84 | .desc = "Output file to write to (default stdout)", | 84 | .desc = "Output file to write to (default stdout)", |
85 | .type = OPTION_ARG, | 85 | .type = OPTION_ARG, |
86 | .opt.arg = &nseq_config.outfile, | 86 | .opt.arg = &cfg.outfile, |
87 | }, | 87 | }, |
88 | { | 88 | { |
89 | .name = "toseq", | 89 | .name = "toseq", |
90 | .desc = "Convert certificates to Netscape certificate sequence", | 90 | .desc = "Convert certificates to Netscape certificate sequence", |
91 | .type = OPTION_FLAG, | 91 | .type = OPTION_FLAG, |
92 | .opt.flag = &nseq_config.toseq, | 92 | .opt.flag = &cfg.toseq, |
93 | }, | 93 | }, |
94 | { NULL }, | 94 | { NULL }, |
95 | }; | 95 | }; |
@@ -114,39 +114,39 @@ nseq_main(int argc, char **argv) | |||
114 | exit(1); | 114 | exit(1); |
115 | } | 115 | } |
116 | 116 | ||
117 | memset(&nseq_config, 0, sizeof(nseq_config)); | 117 | memset(&cfg, 0, sizeof(cfg)); |
118 | 118 | ||
119 | if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) { | 119 | if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) { |
120 | nseq_usage(); | 120 | nseq_usage(); |
121 | return (1); | 121 | return (1); |
122 | } | 122 | } |
123 | 123 | ||
124 | if (nseq_config.infile) { | 124 | if (cfg.infile) { |
125 | if (!(in = BIO_new_file(nseq_config.infile, "r"))) { | 125 | if (!(in = BIO_new_file(cfg.infile, "r"))) { |
126 | BIO_printf(bio_err, | 126 | BIO_printf(bio_err, |
127 | "Can't open input file %s\n", nseq_config.infile); | 127 | "Can't open input file %s\n", cfg.infile); |
128 | goto end; | 128 | goto end; |
129 | } | 129 | } |
130 | } else | 130 | } else |
131 | in = BIO_new_fp(stdin, BIO_NOCLOSE); | 131 | in = BIO_new_fp(stdin, BIO_NOCLOSE); |
132 | 132 | ||
133 | if (nseq_config.outfile) { | 133 | if (cfg.outfile) { |
134 | if (!(out = BIO_new_file(nseq_config.outfile, "w"))) { | 134 | if (!(out = BIO_new_file(cfg.outfile, "w"))) { |
135 | BIO_printf(bio_err, | 135 | BIO_printf(bio_err, |
136 | "Can't open output file %s\n", nseq_config.outfile); | 136 | "Can't open output file %s\n", cfg.outfile); |
137 | goto end; | 137 | goto end; |
138 | } | 138 | } |
139 | } else { | 139 | } else { |
140 | out = BIO_new_fp(stdout, BIO_NOCLOSE); | 140 | out = BIO_new_fp(stdout, BIO_NOCLOSE); |
141 | } | 141 | } |
142 | if (nseq_config.toseq) { | 142 | if (cfg.toseq) { |
143 | seq = NETSCAPE_CERT_SEQUENCE_new(); | 143 | seq = NETSCAPE_CERT_SEQUENCE_new(); |
144 | seq->certs = sk_X509_new_null(); | 144 | seq->certs = sk_X509_new_null(); |
145 | while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) | 145 | while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) |
146 | sk_X509_push(seq->certs, x509); | 146 | sk_X509_push(seq->certs, x509); |
147 | 147 | ||
148 | if (!sk_X509_num(seq->certs)) { | 148 | if (!sk_X509_num(seq->certs)) { |
149 | BIO_printf(bio_err, "Error reading certs file %s\n", nseq_config.infile); | 149 | BIO_printf(bio_err, "Error reading certs file %s\n", cfg.infile); |
150 | ERR_print_errors(bio_err); | 150 | ERR_print_errors(bio_err); |
151 | goto end; | 151 | goto end; |
152 | } | 152 | } |
@@ -155,7 +155,7 @@ nseq_main(int argc, char **argv) | |||
155 | goto end; | 155 | goto end; |
156 | } | 156 | } |
157 | if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { | 157 | if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { |
158 | BIO_printf(bio_err, "Error reading sequence file %s\n", nseq_config.infile); | 158 | BIO_printf(bio_err, "Error reading sequence file %s\n", cfg.infile); |
159 | ERR_print_errors(bio_err); | 159 | ERR_print_errors(bio_err); |
160 | goto end; | 160 | goto end; |
161 | } | 161 | } |