=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/openssl/Attic/nseq.c,v retrieving revision 1.10 retrieving revision 1.11 diff -c -r1.10 -r1.11 *** src/usr.bin/openssl/Attic/nseq.c 2022/11/11 17:07:39 1.10 --- src/usr.bin/openssl/Attic/nseq.c 2023/03/06 14:32:06 1.11 *************** *** 1,4 **** ! /* $OpenBSD: nseq.c,v 1.10 2022/11/11 17:07:39 joshua Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ --- 1,4 ---- ! /* $OpenBSD: nseq.c,v 1.11 2023/03/06 14:32:06 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 1999. */ *************** *** 68,74 **** char *infile; char *outfile; int toseq; ! } nseq_config; static const struct option nseq_options[] = { { --- 68,74 ---- char *infile; char *outfile; int toseq; ! } cfg; static const struct option nseq_options[] = { { *************** *** 76,95 **** .argname = "file", .desc = "Input file to read from (default stdin)", .type = OPTION_ARG, ! .opt.arg = &nseq_config.infile, }, { .name = "out", .argname = "file", .desc = "Output file to write to (default stdout)", .type = OPTION_ARG, ! .opt.arg = &nseq_config.outfile, }, { .name = "toseq", .desc = "Convert certificates to Netscape certificate sequence", .type = OPTION_FLAG, ! .opt.flag = &nseq_config.toseq, }, { NULL }, }; --- 76,95 ---- .argname = "file", .desc = "Input file to read from (default stdin)", .type = OPTION_ARG, ! .opt.arg = &cfg.infile, }, { .name = "out", .argname = "file", .desc = "Output file to write to (default stdout)", .type = OPTION_ARG, ! .opt.arg = &cfg.outfile, }, { .name = "toseq", .desc = "Convert certificates to Netscape certificate sequence", .type = OPTION_FLAG, ! .opt.flag = &cfg.toseq, }, { NULL }, }; *************** *** 114,152 **** exit(1); } ! memset(&nseq_config, 0, sizeof(nseq_config)); if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) { nseq_usage(); return (1); } ! if (nseq_config.infile) { ! if (!(in = BIO_new_file(nseq_config.infile, "r"))) { BIO_printf(bio_err, ! "Can't open input file %s\n", nseq_config.infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); ! if (nseq_config.outfile) { ! if (!(out = BIO_new_file(nseq_config.outfile, "w"))) { BIO_printf(bio_err, ! "Can't open output file %s\n", nseq_config.outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } ! if (nseq_config.toseq) { seq = NETSCAPE_CERT_SEQUENCE_new(); seq->certs = sk_X509_new_null(); while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) sk_X509_push(seq->certs, x509); if (!sk_X509_num(seq->certs)) { ! BIO_printf(bio_err, "Error reading certs file %s\n", nseq_config.infile); ERR_print_errors(bio_err); goto end; } --- 114,152 ---- exit(1); } ! memset(&cfg, 0, sizeof(cfg)); if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) { nseq_usage(); return (1); } ! if (cfg.infile) { ! if (!(in = BIO_new_file(cfg.infile, "r"))) { BIO_printf(bio_err, ! "Can't open input file %s\n", cfg.infile); goto end; } } else in = BIO_new_fp(stdin, BIO_NOCLOSE); ! if (cfg.outfile) { ! if (!(out = BIO_new_file(cfg.outfile, "w"))) { BIO_printf(bio_err, ! "Can't open output file %s\n", cfg.outfile); goto end; } } else { out = BIO_new_fp(stdout, BIO_NOCLOSE); } ! if (cfg.toseq) { seq = NETSCAPE_CERT_SEQUENCE_new(); seq->certs = sk_X509_new_null(); while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL))) sk_X509_push(seq->certs, x509); if (!sk_X509_num(seq->certs)) { ! BIO_printf(bio_err, "Error reading certs file %s\n", cfg.infile); ERR_print_errors(bio_err); goto end; } *************** *** 155,161 **** goto end; } if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { ! BIO_printf(bio_err, "Error reading sequence file %s\n", nseq_config.infile); ERR_print_errors(bio_err); goto end; } --- 155,161 ---- goto end; } if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) { ! BIO_printf(bio_err, "Error reading sequence file %s\n", cfg.infile); ERR_print_errors(bio_err); goto end; }