[BACK]Return to nseq.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / openssl

Diff for /src/usr.bin/openssl/Attic/nseq.c between version 1.10 and 1.11

version 1.10, 2022/11/11 17:07:39 version 1.11, 2023/03/06 14:32:06
Line 68 
Line 68 
         char *infile;          char *infile;
         char *outfile;          char *outfile;
         int toseq;          int toseq;
 } nseq_config;  } cfg;
   
 static const struct option nseq_options[] = {  static const struct option nseq_options[] = {
         {          {
Line 76 
Line 76 
                 .argname = "file",                  .argname = "file",
                 .desc = "Input file to read from (default stdin)",                  .desc = "Input file to read from (default stdin)",
                 .type = OPTION_ARG,                  .type = OPTION_ARG,
                 .opt.arg = &nseq_config.infile,                  .opt.arg = &cfg.infile,
         },          },
         {          {
                 .name = "out",                  .name = "out",
                 .argname = "file",                  .argname = "file",
                 .desc = "Output file to write to (default stdout)",                  .desc = "Output file to write to (default stdout)",
                 .type = OPTION_ARG,                  .type = OPTION_ARG,
                 .opt.arg = &nseq_config.outfile,                  .opt.arg = &cfg.outfile,
         },          },
         {          {
                 .name = "toseq",                  .name = "toseq",
                 .desc = "Convert certificates to Netscape certificate sequence",                  .desc = "Convert certificates to Netscape certificate sequence",
                 .type = OPTION_FLAG,                  .type = OPTION_FLAG,
                 .opt.flag = &nseq_config.toseq,                  .opt.flag = &cfg.toseq,
         },          },
         { NULL },          { NULL },
 };  };
Line 114 
Line 114 
                 exit(1);                  exit(1);
         }          }
   
         memset(&nseq_config, 0, sizeof(nseq_config));          memset(&cfg, 0, sizeof(cfg));
   
         if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) {          if (options_parse(argc, argv, nseq_options, NULL, NULL) != 0) {
                 nseq_usage();                  nseq_usage();
                 return (1);                  return (1);
         }          }
   
         if (nseq_config.infile) {          if (cfg.infile) {
                 if (!(in = BIO_new_file(nseq_config.infile, "r"))) {                  if (!(in = BIO_new_file(cfg.infile, "r"))) {
                         BIO_printf(bio_err,                          BIO_printf(bio_err,
                             "Can't open input file %s\n", nseq_config.infile);                              "Can't open input file %s\n", cfg.infile);
                         goto end;                          goto end;
                 }                  }
         } else          } else
                 in = BIO_new_fp(stdin, BIO_NOCLOSE);                  in = BIO_new_fp(stdin, BIO_NOCLOSE);
   
         if (nseq_config.outfile) {          if (cfg.outfile) {
                 if (!(out = BIO_new_file(nseq_config.outfile, "w"))) {                  if (!(out = BIO_new_file(cfg.outfile, "w"))) {
                         BIO_printf(bio_err,                          BIO_printf(bio_err,
                             "Can't open output file %s\n", nseq_config.outfile);                              "Can't open output file %s\n", cfg.outfile);
                         goto end;                          goto end;
                 }                  }
         } else {          } else {
                 out = BIO_new_fp(stdout, BIO_NOCLOSE);                  out = BIO_new_fp(stdout, BIO_NOCLOSE);
         }          }
         if (nseq_config.toseq) {          if (cfg.toseq) {
                 seq = NETSCAPE_CERT_SEQUENCE_new();                  seq = NETSCAPE_CERT_SEQUENCE_new();
                 seq->certs = sk_X509_new_null();                  seq->certs = sk_X509_new_null();
                 while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL)))                  while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL)))
                         sk_X509_push(seq->certs, x509);                          sk_X509_push(seq->certs, x509);
   
                 if (!sk_X509_num(seq->certs)) {                  if (!sk_X509_num(seq->certs)) {
                         BIO_printf(bio_err, "Error reading certs file %s\n", nseq_config.infile);                          BIO_printf(bio_err, "Error reading certs file %s\n", cfg.infile);
                         ERR_print_errors(bio_err);                          ERR_print_errors(bio_err);
                         goto end;                          goto end;
                 }                  }
Line 155 
Line 155 
                 goto end;                  goto end;
         }          }
         if (!(seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL))) {          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);                  BIO_printf(bio_err, "Error reading sequence file %s\n", cfg.infile);
                 ERR_print_errors(bio_err);                  ERR_print_errors(bio_err);
                 goto end;                  goto end;
         }          }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11