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


apps/pkeyparam.c:34:1: start of procedure pkeyparam_main()
32.   };
33.   
34. > int pkeyparam_main(int argc, char **argv)
35.   {
36.       BIO *in = NULL, *out = NULL;

apps/pkeyparam.c:36:5: 
34.   int pkeyparam_main(int argc, char **argv)
35.   {
36. >     BIO *in = NULL, *out = NULL;
37.       EVP_PKEY *pkey = NULL;
38.       int text = 0, noout = 0, ret = 1;

apps/pkeyparam.c:37:5: 
35.   {
36.       BIO *in = NULL, *out = NULL;
37. >     EVP_PKEY *pkey = NULL;
38.       int text = 0, noout = 0, ret = 1;
39.       OPTION_CHOICE o;

apps/pkeyparam.c:38:5: 
36.       BIO *in = NULL, *out = NULL;
37.       EVP_PKEY *pkey = NULL;
38. >     int text = 0, noout = 0, ret = 1;
39.       OPTION_CHOICE o;
40.       char *infile = NULL, *outfile = NULL, *prog;

apps/pkeyparam.c:40:5: 
38.       int text = 0, noout = 0, ret = 1;
39.       OPTION_CHOICE o;
40. >     char *infile = NULL, *outfile = NULL, *prog;
41.   
42.       prog = opt_init(argc, argv, pkeyparam_options);

apps/pkeyparam.c:42:5: Skipping opt_init(): empty list of specs
40.       char *infile = NULL, *outfile = NULL, *prog;
41.   
42.       prog = opt_init(argc, argv, pkeyparam_options);
          ^
43.       while ((o = opt_next()) != OPT_EOF) {
44.           switch (o) {

apps/pkeyparam.c:43:12: Loop condition is false. Leaving loop
41.   
42.       prog = opt_init(argc, argv, pkeyparam_options);
43.       while ((o = opt_next()) != OPT_EOF) {
                 ^
44.           switch (o) {
45.           case OPT_EOF:

apps/pkeyparam.c:71:5: 
69.           }
70.       }
71. >     argc = opt_num_rest();
72.       if (argc != 0)
73.           goto opthelp;

apps/opt.c:774:1: start of procedure opt_num_rest()
  772.   
  773.   /* How many items in remaining args? */
  774. > int opt_num_rest(void)
  775.   {
  776.       int i = 0;

apps/opt.c:776:5: 
  774.   int opt_num_rest(void)
  775.   {
  776. >     int i = 0;
  777.       char **pp;
  778.   

apps/opt.c:779:10: 
  777.       char **pp;
  778.   
  779. >     for (pp = opt_rest(); *pp; pp++, i++)
  780.           continue;
  781.       return i;

apps/opt.c:768:1: start of procedure opt_rest()
    766.   
    767.   /* Return the rest of the arguments after parsing flags. */
    768. > char **opt_rest(void)
    769.   {
    770.       return &argv[opt_index];

apps/opt.c:770:5: 
    768.   char **opt_rest(void)
    769.   {
    770. >     return &argv[opt_index];
    771.   }
    772.   

apps/opt.c:771:1: return from a call to opt_rest
    769.   {
    770.       return &argv[opt_index];
    771. > }
    772.   
    773.   /* How many items in remaining args? */

apps/opt.c:779:27: Loop condition is false. Leaving loop
  777.       char **pp;
  778.   
  779.       for (pp = opt_rest(); *pp; pp++, i++)
                                   ^
  780.           continue;
  781.       return i;

apps/opt.c:781:5: 
  779.       for (pp = opt_rest(); *pp; pp++, i++)
  780.           continue;
  781. >     return i;
  782.   }
  783.   

apps/opt.c:782:1: return from a call to opt_num_rest
  780.           continue;
  781.       return i;
  782. > }
  783.   
  784.   /* Return a string describing the parameter type. */

apps/pkeyparam.c:72:9: Taking false branch
70.       }
71.       argc = opt_num_rest();
72.       if (argc != 0)
              ^
73.           goto opthelp;
74.   

apps/pkeyparam.c:75:5: 
73.           goto opthelp;
74.   
75. >     in = bio_open_default(infile, 'r', FORMAT_PEM);
76.       if (in == NULL)
77.           goto end;

apps/apps.c:2517:1: start of procedure bio_open_default()
  2515.   }
  2516.   
  2517. > BIO *bio_open_default(const char *filename, char mode, int format)
  2518.   {
  2519.       return bio_open_default_(filename, mode, format, 0);

apps/apps.c:2519:5: 
  2517.   BIO *bio_open_default(const char *filename, char mode, int format)
  2518.   {
  2519. >     return bio_open_default_(filename, mode, format, 0);
  2520.   }
  2521.   

apps/apps.c:2485:1: start of procedure bio_open_default_()
    2483.   }
    2484.   
    2485. > static BIO *bio_open_default_(const char *filename, char mode, int format,
    2486.                                 int quiet)
    2487.   {

apps/apps.c:2490:9: Taking false branch
    2488.       BIO *ret;
    2489.   
    2490.       if (filename == NULL || strcmp(filename, "-") == 0) {
                    ^
    2491.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2492.           if (quiet) {

apps/apps.c:2490:29: Taking true branch
    2488.       BIO *ret;
    2489.   
    2490.       if (filename == NULL || strcmp(filename, "-") == 0) {
                                        ^
    2491.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2492.           if (quiet) {

apps/apps.c:2491:15: Condition is true
    2489.   
    2490.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2491.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
                          ^
    2492.           if (quiet) {
    2493.               ERR_clear_error();

apps/apps.c:2346:1: start of procedure dup_bio_in()
      2344.   }
      2345.   
      2346. > BIO *dup_bio_in(int format)
      2347.   {
      2348.       return BIO_new_fp(stdin,

apps/apps.c:2349:38: 
      2347.   {
      2348.       return BIO_new_fp(stdin,
      2349. >                       BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2350.   }
      2351.   

apps/apps.c:2341:1: start of procedure istext()
        2339.    * text and binary input/output on non-Unix platforms
        2340.    */
        2341. > static int istext(int format)
        2342.   {
        2343.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;

apps/apps.c:2343:12: Condition is true
        2341.   static int istext(int format)
        2342.   {
        2343.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
                           ^
        2344.   }
        2345.   

apps/apps.c:2343:5: 
        2341.   static int istext(int format)
        2342.   {
        2343. >     return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
        2344.   }
        2345.   

apps/apps.c:2344:1: return from a call to istext
        2342.   {
        2343.       return (format & B_FORMAT_TEXT) == B_FORMAT_TEXT;
        2344. > }
        2345.   
        2346.   BIO *dup_bio_in(int format)

apps/apps.c:2349:38: Condition is true
      2347.   {
      2348.       return BIO_new_fp(stdin,
      2349.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
                                                   ^
      2350.   }
      2351.   

apps/apps.c:2348:5: Skipping BIO_new_fp(): empty list of specs
      2346.   BIO *dup_bio_in(int format)
      2347.   {
      2348.       return BIO_new_fp(stdin,
                  ^
      2349.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2350.   }

apps/apps.c:2350:1: return from a call to dup_bio_in
      2348.       return BIO_new_fp(stdin,
      2349.                         BIO_NOCLOSE | (istext(format) ? BIO_FP_TEXT : 0));
      2350. > }
      2351.   
      2352.   BIO *dup_bio_out(int format)

apps/apps.c:2491:9: 
    2489.   
    2490.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2491. >         ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2492.           if (quiet) {
    2493.               ERR_clear_error();

apps/apps.c:2492:13: Taking false branch
    2490.       if (filename == NULL || strcmp(filename, "-") == 0) {
    2491.           ret = mode == 'r' ? dup_bio_in(format) : dup_bio_out(format);
    2492.           if (quiet) {
                        ^
    2493.               ERR_clear_error();
    2494.               return ret;

apps/apps.c:2496:13: Taking true branch
    2494.               return ret;
    2495.           }
    2496.           if (ret != NULL)
                        ^
    2497.               return ret;
    2498.           BIO_printf(bio_err,

apps/apps.c:2497:13: 
    2495.           }
    2496.           if (ret != NULL)
    2497. >             return ret;
    2498.           BIO_printf(bio_err,
    2499.                      "Can't open %s, %s\n",

apps/apps.c:2515:1: return from a call to bio_open_default_
    2513.       ERR_print_errors(bio_err);
    2514.       return NULL;
    2515. > }
    2516.   
    2517.   BIO *bio_open_default(const char *filename, char mode, int format)

apps/apps.c:2520:1: return from a call to bio_open_default
  2518.   {
  2519.       return bio_open_default_(filename, mode, format, 0);
  2520. > }
  2521.   
  2522.   BIO *bio_open_default_quiet(const char *filename, char mode, int format)

int pkeyparam_main(int argc, char **argv)
{
    BIO *in = NULL, *out = NULL;
    EVP_PKEY *pkey = NULL;
    int text = 0, noout = 0, ret = 1;
    OPTION_CHOICE o;
    char *infile = NULL, *outfile = NULL, *prog;
    prog = opt_init(argc, argv, pkeyparam_options);
    while ((o = opt_next()) != OPT_EOF) {
        switch (o) {
        case OPT_EOF:
        case OPT_ERR:
 opthelp:
            BIO_printf(bio_err, "%s: Use -help for summary.\n", prog);
            goto end;
        case OPT_HELP:
            opt_help(pkeyparam_options);
            ret = 0;
            goto end;
        case OPT_IN:
            infile = opt_arg();
            break;
        case OPT_OUT:
            outfile = opt_arg();
            break;
        case OPT_ENGINE:
            (void)setup_engine(opt_arg(), 0);
            break;
        case OPT_TEXT:
            text = 1;
            break;
        case OPT_NOOUT:
            noout = 1;
            break;
        }
    }
    argc = opt_num_rest();
    if (argc != 0)
        goto opthelp;
    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;
    pkey = PEM_read_bio_Parameters(in, NULL);
    if (!pkey) {
        BIO_printf(bio_err, "Error reading parameters\n");
        ERR_print_errors(bio_err);
        goto end;
    }
    if (!noout)
        PEM_write_bio_Parameters(out, pkey);
    if (text)
        EVP_PKEY_print_params(out, pkey, 0, NULL);
    ret = 0;
 end:
    EVP_PKEY_free(pkey);
    BIO_free_all(out);
    BIO_free(in);
    return ret;
}
['int pkeyparam_main(int argc, char **argv)\n{\n    BIO *in = NULL, *out = NULL;\n    EVP_PKEY *pkey = NULL;\n    int text = 0, noout = 0, ret = 1;\n    OPTION_CHOICE o;\n    char *infile = NULL, *outfile = NULL, *prog;\n    prog = opt_init(argc, argv, pkeyparam_options);\n    while ((o = opt_next()) != OPT_EOF) {\n        switch (o) {\n        case OPT_EOF:\n        case OPT_ERR:\n opthelp:\n            BIO_printf(bio_err, "%s: Use -help for summary.\\n", prog);\n            goto end;\n        case OPT_HELP:\n            opt_help(pkeyparam_options);\n            ret = 0;\n            goto end;\n        case OPT_IN:\n            infile = opt_arg();\n            break;\n        case OPT_OUT:\n            outfile = opt_arg();\n            break;\n        case OPT_ENGINE:\n            (void)setup_engine(opt_arg(), 0);\n            break;\n        case OPT_TEXT:\n            text = 1;\n            break;\n        case OPT_NOOUT:\n            noout = 1;\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    if (argc != 0)\n        goto opthelp;\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    pkey = PEM_read_bio_Parameters(in, NULL);\n    if (!pkey) {\n        BIO_printf(bio_err, "Error reading parameters\\n");\n        ERR_print_errors(bio_err);\n        goto end;\n    }\n    if (!noout)\n        PEM_write_bio_Parameters(out, pkey);\n    if (text)\n        EVP_PKEY_print_params(out, pkey, 0, NULL);\n    ret = 0;\n end:\n    EVP_PKEY_free(pkey);\n    BIO_free_all(out);\n    BIO_free(in);\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}']