apps/nseq.c:112: error: NULL_DEREFERENCE
  pointer `infile` last assigned on line 85 could be null and is dereferenced by call to `bio_open_default()` at line 112, column 10.
Showing all 56 steps of the trace


apps/nseq.c:78:1: start of procedure nseq_main()
76.   };
77.   
78. > int nseq_main(int argc, char **argv)
79.   {
80.       BIO *in = NULL, *out = NULL;

apps/nseq.c:80:5: 
78.   int nseq_main(int argc, char **argv)
79.   {
80. >     BIO *in = NULL, *out = NULL;
81.       X509 *x509 = NULL;
82.       NETSCAPE_CERT_SEQUENCE *seq = NULL;

apps/nseq.c:81:5: 
79.   {
80.       BIO *in = NULL, *out = NULL;
81. >     X509 *x509 = NULL;
82.       NETSCAPE_CERT_SEQUENCE *seq = NULL;
83.       OPTION_CHOICE o;

apps/nseq.c:82:5: 
80.       BIO *in = NULL, *out = NULL;
81.       X509 *x509 = NULL;
82. >     NETSCAPE_CERT_SEQUENCE *seq = NULL;
83.       OPTION_CHOICE o;
84.       int toseq = 0, ret = 1, i;

apps/nseq.c:84:5: 
82.       NETSCAPE_CERT_SEQUENCE *seq = NULL;
83.       OPTION_CHOICE o;
84. >     int toseq = 0, ret = 1, i;
85.       char *infile = NULL, *outfile = NULL, *prog;
86.   

apps/nseq.c:85:5: 
83.       OPTION_CHOICE o;
84.       int toseq = 0, ret = 1, i;
85. >     char *infile = NULL, *outfile = NULL, *prog;
86.   
87.       prog = opt_init(argc, argv, nseq_options);

apps/nseq.c:87:5: Skipping opt_init(): empty list of specs
85.       char *infile = NULL, *outfile = NULL, *prog;
86.   
87.       prog = opt_init(argc, argv, nseq_options);
          ^
88.       while ((o = opt_next()) != OPT_EOF) {
89.           switch (o) {

apps/nseq.c:88:12: Loop condition is false. Leaving loop
86.   
87.       prog = opt_init(argc, argv, nseq_options);
88.       while ((o = opt_next()) != OPT_EOF) {
                 ^
89.           switch (o) {
90.           case OPT_EOF:

apps/nseq.c:109:5: 
107.           }
108.       }
109. >     argc = opt_num_rest();
110.       argv = opt_rest();
111.   

apps/opt.c:720:1: start of procedure opt_num_rest()
  718.   
  719.   /* How many items in remaining args? */
  720. > int opt_num_rest(void)
  721.   {
  722.       int i = 0;

apps/opt.c:722:5: 
  720.   int opt_num_rest(void)
  721.   {
  722. >     int i = 0;
  723.       char **pp;
  724.   

apps/opt.c:725:10: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:714:1: start of procedure opt_rest()
    712.   
    713.   /* Return the rest of the arguments after parsing flags. */
    714. > char **opt_rest(void)
    715.   {
    716.       return &argv[opt_index];

apps/opt.c:716:5: 
    714.   char **opt_rest(void)
    715.   {
    716. >     return &argv[opt_index];
    717.   }
    718.   

apps/opt.c:717:1: return from a call to opt_rest
    715.   {
    716.       return &argv[opt_index];
    717. > }
    718.   
    719.   /* How many items in remaining args? */

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is true. Entering loop body
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:725:32: 
  723.       char **pp;
  724.   
  725. >     for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727.       return i;

apps/opt.c:725:27: Loop condition is false. Leaving loop
  723.       char **pp;
  724.   
  725.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  726.           continue;
  727.       return i;

apps/opt.c:727:5: 
  725.       for (pp = opt_rest(); *pp; pp++, i++)
  726.           continue;
  727. >     return i;
  728.   }
  729.   

apps/opt.c:728:1: return from a call to opt_num_rest
  726.           continue;
  727.       return i;
  728. > }
  729.   
  730.   /* Return a string describing the parameter type. */

apps/nseq.c:110:5: 
108.       }
109.       argc = opt_num_rest();
110. >     argv = opt_rest();
111.   
112.       in = bio_open_default(infile, 'r', FORMAT_PEM);

apps/opt.c:714:1: start of procedure opt_rest()
  712.   
  713.   /* Return the rest of the arguments after parsing flags. */
  714. > char **opt_rest(void)
  715.   {
  716.       return &argv[opt_index];

apps/opt.c:716:5: 
  714.   char **opt_rest(void)
  715.   {
  716. >     return &argv[opt_index];
  717.   }
  718.   

apps/opt.c:717:1: return from a call to opt_rest
  715.   {
  716.       return &argv[opt_index];
  717. > }
  718.   
  719.   /* How many items in remaining args? */

apps/nseq.c:112:5: 
110.       argv = opt_rest();
111.   
112. >     in = bio_open_default(infile, 'r', FORMAT_PEM);
113.       if (in == NULL)
114.           goto end;

apps/apps.c:2880:1: start of procedure bio_open_default()
  2878.   }
  2879.   
  2880. > BIO *bio_open_default(const char *filename, char mode, int format)
  2881.   {
  2882.       return bio_open_default_(filename, mode, format, 0);

apps/apps.c:2882:5: 
  2880.   BIO *bio_open_default(const char *filename, char mode, int format)
  2881.   {
  2882. >     return bio_open_default_(filename, mode, format, 0);
  2883.   }
  2884.   

apps/apps.c:2848:1: start of procedure bio_open_default_()
    2846.   }
    2847.   
    2848. > static BIO *bio_open_default_(const char *filename, char mode, int format,
    2849.                                 int quiet)
    2850.   {

apps/apps.c:2853:9: Taking false branch
    2851.       BIO *ret;
    2852.   
    2853.       if (filename == NULL || strcmp(filename, "-") == 0) {
                    ^
    2854.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2855.           if (quiet) {

apps/apps.c:2853:29: Taking true branch
    2851.       BIO *ret;
    2852.   
    2853.       if (filename == NULL || strcmp(filename, "-") == 0) {
                                        ^
    2854.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2855.           if (quiet) {

apps/apps.c:2854:15: Condition is true
    2852.   
    2853.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2854.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
                          ^
    2855.           if (quiet) {
    2856.               ERR_clear_error();

apps/apps.c:2744:1: start of procedure dup_bio_in()
      2742.   }
      2743.   
      2744. > BIO *dup_bio_in(int format)
      2745.   {
      2746.       return BIO_new_fp(stdin,

apps/apps.c:2747:38: 
      2745.   {
      2746.       return BIO_new_fp(stdin,
      2747. >                       BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2748.   }
      2749.   

apps/apps.c:2739:1: start of procedure istext()
        2737.    * text and binary input/output on non-Unix platforms
        2738.    */
        2739. > static int istext(int format)
        2740.   {
        2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;

apps/apps.c:2741:12: Condition is true
        2739.   static int istext(int format)
        2740.   {
        2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
                           ^
        2742.   }
        2743.   

apps/apps.c:2741:5: 
        2739.   static int istext(int format)
        2740.   {
        2741. >     return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
        2742.   }
        2743.   

apps/apps.c:2742:1: return from a call to istext
        2740.   {
        2741.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
        2742. > }
        2743.   
        2744.   BIO *dup_bio_in(int format)

apps/apps.c:2747:38: Condition is true
      2745.   {
      2746.       return BIO_new_fp(stdin,
      2747.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
                                                   ^
      2748.   }
      2749.   

apps/apps.c:2746:5: Skipping BIO_new_fp(): empty list of specs
      2744.   BIO *dup_bio_in(int format)
      2745.   {
      2746.       return BIO_new_fp(stdin,
                  ^
      2747.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2748.   }

apps/apps.c:2748:1: return from a call to dup_bio_in
      2746.       return BIO_new_fp(stdin,
      2747.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2748. > }
      2749.   
      2750.   BIO *dup_bio_out(int format)

apps/apps.c:2854:9: 
    2852.   
    2853.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2854. >         ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2855.           if (quiet) {
    2856.               ERR_clear_error();

apps/apps.c:2855:13: Taking false branch
    2853.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2854.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2855.           if (quiet) {
                        ^
    2856.               ERR_clear_error();
    2857.               return ret;

apps/apps.c:2859:13: Taking true branch
    2857.               return ret;
    2858.           }
    2859.           if (ret != NULL)
                        ^
    2860.               return ret;
    2861.           BIO_printf(bio_err,

apps/apps.c:2860:13: 
    2858.           }
    2859.           if (ret != NULL)
    2860. >             return ret;
    2861.           BIO_printf(bio_err,
    2862.                      "Can't open %s, %s\n",

apps/apps.c:2878:1: return from a call to bio_open_default_
    2876.       ERR_print_errors(bio_err);
    2877.       return NULL;
    2878. > }
    2879.   
    2880.   BIO *bio_open_default(const char *filename, char mode, int format)

apps/apps.c:2883:1: return from a call to bio_open_default
  2881.   {
  2882.       return bio_open_default_(filename, mode, format, 0);
  2883. > }
  2884.   
  2885.   BIO *bio_open_default_quiet(const char *filename, char mode, int format)

int nseq_main(int argc, char **argv)
{
    BIO *in = NULL, *out = NULL;
    X509 *x509 = NULL;
    NETSCAPE_CERT_SEQUENCE *seq = NULL;
    OPTION_CHOICE o;
    int toseq = 0, ret = 1, i;
    char *infile = NULL, *outfile = NULL, *prog;
    prog = opt_init(argc, argv, nseq_options);
    while ((o = opt_next()) != OPT_EOF) {
        switch (o) {
        case OPT_EOF:
        case OPT_ERR:
            BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
            goto end;
        case OPT_HELP:
            ret = 0;
            opt_help(nseq_options);
            goto end;
        case OPT_TOSEQ:
            toseq = 1;
            break;
        case OPT_IN:
            infile = opt_arg();
            break;
        case OPT_OUT:
            outfile = opt_arg();
            break;
        }
    }
    argc = opt_num_rest();
    argv = opt_rest();
    in = bio_open_default(infile, 'r', FORMAT_PEM);
    if (in == NULL)
        goto end;
    out = bio_open_default(outfile, 'w', FORMAT_PEM);
    if (out == NULL)
        goto end;
    if (toseq) {
        seq = NETSCAPE_CERT_SEQUENCE_new();
        seq->certs = sk_X509_new_null();
        if (!seq->certs)
            goto end;
        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, "%s: Error reading certs file %s\n",
                       prog, infile);
            ERR_print_errors(bio_err);
            goto end;
        }
        PEM_write_bio_NETSCAPE_CERT_SEQUENCE(out, seq);
        ret = 0;
        goto end;
    }
    seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL);
    if (seq == NULL) {
        BIO_printf(bio_err, "%s: Error reading sequence file %s\n",
                   prog, infile);
        ERR_print_errors(bio_err);
        goto end;
    }
    for (i = 0; i < sk_X509_num(seq->certs); i++) {
        x509 = sk_X509_value(seq->certs, i);
        dump_cert_text(out, x509);
        PEM_write_bio_X509(out, x509);
    }
    ret = 0;
 end:
    BIO_free(in);
    BIO_free_all(out);
    NETSCAPE_CERT_SEQUENCE_free(seq);
    return (ret);
}
['int nseq_main(int argc, char **argv)\n{\n    BIO *in = NULL, *out = NULL;\n    X509 *x509 = NULL;\n    NETSCAPE_CERT_SEQUENCE *seq = NULL;\n    OPTION_CHOICE o;\n    int toseq = 0, ret = 1, i;\n    char *infile = NULL, *outfile = NULL, *prog;\n    prog = opt_init(argc, argv, nseq_options);\n    while ((o = opt_next()) != OPT_EOF) {\n        switch (o) {\n        case OPT_EOF:\n        case OPT_ERR:\n            BIO_printf(bio_err, "%s: Use -help for summary.\\n", prog);\n            goto end;\n        case OPT_HELP:\n            ret = 0;\n            opt_help(nseq_options);\n            goto end;\n        case OPT_TOSEQ:\n            toseq = 1;\n            break;\n        case OPT_IN:\n            infile = opt_arg();\n            break;\n        case OPT_OUT:\n            outfile = opt_arg();\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    argv = opt_rest();\n    in = bio_open_default(infile, \'r\', FORMAT_PEM);\n    if (in == NULL)\n        goto end;\n    out = bio_open_default(outfile, \'w\', FORMAT_PEM);\n    if (out == NULL)\n        goto end;\n    if (toseq) {\n        seq = NETSCAPE_CERT_SEQUENCE_new();\n        seq->certs = sk_X509_new_null();\n        if (!seq->certs)\n            goto end;\n        while ((x509 = PEM_read_bio_X509(in, NULL, NULL, NULL)))\n            sk_X509_push(seq->certs, x509);\n        if (!sk_X509_num(seq->certs)) {\n            BIO_printf(bio_err, "%s: Error reading certs file %s\\n",\n                       prog, infile);\n            ERR_print_errors(bio_err);\n            goto end;\n        }\n        PEM_write_bio_NETSCAPE_CERT_SEQUENCE(out, seq);\n        ret = 0;\n        goto end;\n    }\n    seq = PEM_read_bio_NETSCAPE_CERT_SEQUENCE(in, NULL, NULL, NULL);\n    if (seq == NULL) {\n        BIO_printf(bio_err, "%s: Error reading sequence file %s\\n",\n                   prog, infile);\n        ERR_print_errors(bio_err);\n        goto end;\n    }\n    for (i = 0; i < sk_X509_num(seq->certs); i++) {\n        x509 = sk_X509_value(seq->certs, i);\n        dump_cert_text(out, x509);\n        PEM_write_bio_X509(out, x509);\n    }\n    ret = 0;\n end:\n    BIO_free(in);\n    BIO_free_all(out);\n    NETSCAPE_CERT_SEQUENCE_free(seq);\n    return (ret);\n}', 'int opt_num_rest(void)\n{\n    int i = 0;\n    char **pp;\n    for (pp = opt_rest(); *pp; pp++, i++)\n        continue;\n    return i;\n}', 'char **opt_rest(void)\n{\n    return &argv[opt_index];\n}', 'BIO *bio_open_default(const char *filename, char mode, int format)\n{\n    return bio_open_default_(filename, mode, format, 0);\n}', 'static BIO *bio_open_default_(const char *filename, char mode, int format,\n                              int quiet)\n{\n    BIO *ret;\n    if (filename == NULL || strcmp(filename, "-") == 0) {\n        ret = mode == \'r\' ? dup_bio_in(format) : dup_bio_out(format);\n        if (quiet) {\n            ERR_clear_error();\n            return ret;\n        }\n        if (ret != NULL)\n            return ret;\n        BIO_printf(bio_err,\n                   "Can\'t open %s, %s\\n",\n                   mode == \'r\' ? "stdin" : "stdout", strerror(errno));\n    } else {\n        ret = BIO_new_file(filename, modestr(mode, format));\n        if (quiet) {\n            ERR_clear_error();\n            return ret;\n        }\n        if (ret != NULL)\n            return ret;\n        BIO_printf(bio_err,\n                   "Can\'t open %s for %s, %s\\n",\n                   filename, modeverb(mode), strerror(errno));\n    }\n    ERR_print_errors(bio_err);\n    return NULL;\n}', 'BIO *dup_bio_in(int format)\n{\n    return BIO_new_fp(stdin,\n                      BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));\n}', 'static int istext(int format)\n{\n    return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;\n}']