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


apps/passwd.c:115:1: start of procedure passwd_main()
113.   };
114.   
115. > int passwd_main(int argc, char **argv)
116.   {
117.       BIO *in = NULL;

apps/passwd.c:117:5: 
115.   int passwd_main(int argc, char **argv)
116.   {
117. >     BIO *in = NULL;
118.       char *infile = NULL, *salt = NULL, *passwd = NULL, **passwds = NULL;
119.       char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;

apps/passwd.c:118:5: 
116.   {
117.       BIO *in = NULL;
118. >     char *infile = NULL, *salt = NULL, *passwd = NULL, **passwds = NULL;
119.       char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;
120.       OPTION_CHOICE o;

apps/passwd.c:119:5: 
117.       BIO *in = NULL;
118.       char *infile = NULL, *salt = NULL, *passwd = NULL, **passwds = NULL;
119. >     char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;
120.       OPTION_CHOICE o;
121.       int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;

apps/passwd.c:121:5: 
119.       char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;
120.       OPTION_CHOICE o;
121. >     int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;
122.       int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
123.       int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;

apps/passwd.c:122:5: 
120.       OPTION_CHOICE o;
121.       int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;
122. >     int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
123.       int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;
124.       size_t passwd_malloc_size = 0, pw_maxlen = 256;

apps/passwd.c:123:5: 
121.       int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;
122.       int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
123. >     int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;
124.       size_t passwd_malloc_size = 0, pw_maxlen = 256;
125.   

apps/passwd.c:124:5: 
122.       int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
123.       int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;
124. >     size_t passwd_malloc_size = 0, pw_maxlen = 256;
125.   
126.       prog = opt_init(argc, argv, passwd_options);

apps/passwd.c:126:5: Skipping opt_init(): empty list of specs
124.       size_t passwd_malloc_size = 0, pw_maxlen = 256;
125.   
126.       prog = opt_init(argc, argv, passwd_options);
           ^
127.       while ((o = opt_next()) != OPT_EOF) {
128.           switch (o) {

apps/passwd.c:127:12: Loop condition is false. Leaving loop
125.   
126.       prog = opt_init(argc, argv, passwd_options);
127.       while ((o = opt_next()) != OPT_EOF) {
                  ^
128.           switch (o) {
129.           case OPT_EOF:

apps/passwd.c:176:5: 
174.           }
175.       }
176. >     argc = opt_num_rest();
177.       argv = opt_rest();
178.   

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

apps/opt.c:719:5: 
  717.   int opt_num_rest(void)
  718.   {
  719. >     int i = 0;
  720.       char **pp;
  721.   

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

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

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

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

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

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

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

apps/passwd.c:177:5: 
175.       }
176.       argc = opt_num_rest();
177. >     argv = opt_rest();
178.   
179.       if (*argv) {

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

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

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

apps/passwd.c:179:9: Taking false branch
177.       argv = opt_rest();
178.   
179.       if (*argv) {
               ^
180.           if (pw_source_defined)
181.               goto opthelp;

apps/passwd.c:186:10: Taking true branch
184.       }
185.   
186.       if (!usecrypt && !use1 && !useapr1) {
                ^
187.           /* use default */
188.           usecrypt = 1;

apps/passwd.c:186:23: Taking true branch
184.       }
185.   
186.       if (!usecrypt && !use1 && !useapr1) {
                             ^
187.           /* use default */
188.           usecrypt = 1;

apps/passwd.c:186:32: Taking true branch
184.       }
185.   
186.       if (!usecrypt && !use1 && !useapr1) {
                                      ^
187.           /* use default */
188.           usecrypt = 1;

apps/passwd.c:188:9: 
186.       if (!usecrypt && !use1 && !useapr1) {
187.           /* use default */
188. >         usecrypt = 1;
189.       }
190.       if (usecrypt + use1 + useapr1 > 1) {

apps/passwd.c:190:9: Taking false branch
188.           usecrypt = 1;
189.       }
190.       if (usecrypt + use1 + useapr1 > 1) {
               ^
191.           /* conflict */
192.           goto opthelp;

apps/passwd.c:204:10: 
202.   # endif
203.   
204. >     if (!app_load_modules(NULL))
205.           goto end;
206.   

apps/apps.c:539:1: start of procedure app_load_modules()
  537.   }
  538.   
  539. > int app_load_modules(const CONF *config)
  540.   {
  541.       CONF *to_free = NULL;

apps/apps.c:541:5: 
  539.   int app_load_modules(const CONF *config)
  540.   {
  541. >     CONF *to_free = NULL;
  542.   
  543.       if (config == NULL)

apps/apps.c:543:9: Taking true branch
  541.       CONF *to_free = NULL;
  542.   
  543.       if (config == NULL)
                 ^
  544.   	config = to_free = app_load_config_quiet(default_config_file);
  545.       if (config == NULL)

apps/apps.c:544:2: Skipping app_load_config_quiet(): empty list of specs
  542.   
  543.       if (config == NULL)
  544.   	config = to_free = app_load_config_quiet(default_config_file);
          ^
  545.       if (config == NULL)
  546.   	return 1;

apps/apps.c:545:9: Taking true branch
  543.       if (config == NULL)
  544.   	config = to_free = app_load_config_quiet(default_config_file);
  545.       if (config == NULL)
                 ^
  546.   	return 1;
  547.   

apps/apps.c:546:2: 
  544.   	config = to_free = app_load_config_quiet(default_config_file);
  545.       if (config == NULL)
  546. > 	return 1;
  547.   
  548.       if (CONF_modules_load(config, NULL, 0) <= 0) {

apps/apps.c:556:1: return from a call to app_load_modules
  554.       NCONF_free(to_free);
  555.       return 1;
  556. > }
  557.   
  558.   int add_oid_section(CONF *conf)

apps/passwd.c:204:10: Taking false branch
202.   # endif
203.   
204.       if (!app_load_modules(NULL))
                ^
205.           goto end;
206.   

apps/passwd.c:207:9: Taking false branch
205.           goto end;
206.   
207.       if (infile && in_stdin) {
               ^
208.           BIO_printf(bio_err, "%s: Can't combine -in and -stdin\n", prog);
209.           goto end;

apps/passwd.c:212:5: 
210.       }
211.   
212. >     in = bio_open_default(infile, "r");
213.       if (in == NULL)
214.           goto end;

apps/openssl.c:387:1: start of procedure bio_open_default()
  385.   }
  386.   
  387. > BIO *bio_open_default(const char *filename, const char *mode)
  388.   {
  389.       return bio_open_default_(filename, mode, 0);

apps/openssl.c:389:5: 
  387.   BIO *bio_open_default(const char *filename, const char *mode)
  388.   {
  389. >     return bio_open_default_(filename, mode, 0);
  390.   }
  391.   

apps/openssl.c:355:1: start of procedure bio_open_default_()
    353.   }
    354.   
    355. > static BIO *bio_open_default_(const char *filename, const char *mode, int quiet)
    356.   {
    357.       BIO *ret;

apps/openssl.c:359:9: Taking false branch
    357.       BIO *ret;
    358.   
    359.       if (filename == NULL || strcmp(filename, "-") == 0) {
                   ^
    360.           ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
    361.           if (quiet) {

apps/openssl.c:359:29: Taking true branch
    357.       BIO *ret;
    358.   
    359.       if (filename == NULL || strcmp(filename, "-") == 0) {
                                       ^
    360.           ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
    361.           if (quiet) {

apps/openssl.c:360:15: Condition is true
    358.   
    359.       if (filename == NULL || strcmp(filename, "-") == 0) {
    360.           ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
                         ^
    361.           if (quiet) {
    362.               ERR_clear_error();

apps/openssl.c:283:1: start of procedure dup_bio_in()
      281.   }
      282.   
      283. > BIO *dup_bio_in(void)
      284.   {
      285.       return BIO_new_fp(stdin, BIO_NOCLOSE | BIO_FP_TEXT);

apps/openssl.c:285:5: Skipping BIO_new_fp(): empty list of specs
      283.   BIO *dup_bio_in(void)
      284.   {
      285.       return BIO_new_fp(stdin, BIO_NOCLOSE | BIO_FP_TEXT);
                 ^
      286.   }
      287.   

apps/openssl.c:286:1: return from a call to dup_bio_in
      284.   {
      285.       return BIO_new_fp(stdin, BIO_NOCLOSE | BIO_FP_TEXT);
      286. > }
      287.   
      288.   BIO *dup_bio_out(void)

apps/openssl.c:360:9: 
    358.   
    359.       if (filename == NULL || strcmp(filename, "-") == 0) {
    360. >         ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
    361.           if (quiet) {
    362.               ERR_clear_error();

apps/openssl.c:361:13: Taking false branch
    359.       if (filename == NULL || strcmp(filename, "-") == 0) {
    360.           ret = *mode == 'r' ? dup_bio_in() : dup_bio_out();
    361.           if (quiet) {
                       ^
    362.               ERR_clear_error();
    363.               return ret;

apps/openssl.c:365:13: Taking true branch
    363.               return ret;
    364.           }
    365.           if (ret != NULL)
                       ^
    366.               return ret;
    367.           BIO_printf(bio_err,

apps/openssl.c:366:13: 
    364.           }
    365.           if (ret != NULL)
    366. >             return ret;
    367.           BIO_printf(bio_err,
    368.                      "Can't open %s, %s\n",

apps/openssl.c:385:1: return from a call to bio_open_default_
    383.       ERR_print_errors(bio_err);
    384.       return NULL;
    385. > }
    386.   
    387.   BIO *bio_open_default(const char *filename, const char *mode)

apps/openssl.c:390:1: return from a call to bio_open_default
  388.   {
  389.       return bio_open_default_(filename, mode, 0);
  390. > }
  391.   
  392.   BIO *bio_open_default_quiet(const char *filename, const char *mode)

int passwd_main(int argc, char **argv)
{
    BIO *in = NULL;
    char *infile = NULL, *salt = NULL, *passwd = NULL, **passwds = NULL;
    char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;
    OPTION_CHOICE o;
    int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;
    int passed_salt = 0, quiet = 0, table = 0, reverse = 0;
    int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;
    size_t passwd_malloc_size = 0, pw_maxlen = 256;
    prog = opt_init(argc, argv, passwd_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(passwd_options);
            ret = 0;
            goto end;
        case OPT_IN:
            if (pw_source_defined)
                goto opthelp;
            infile = opt_arg();
            pw_source_defined = 1;
            break;
        case OPT_NOVERIFY:
            in_noverify = 1;
            break;
        case OPT_QUIET:
            quiet = 1;
            break;
        case OPT_TABLE:
            table = 1;
            break;
        case OPT_REVERSE:
            reverse = 1;
            break;
        case OPT_1:
            use1 = 1;
            break;
        case OPT_APR1:
            useapr1 = 1;
            break;
        case OPT_CRYPT:
            usecrypt = 1;
            break;
        case OPT_SALT:
            passed_salt = 1;
            salt = opt_arg();
            break;
        case OPT_STDIN:
            if (pw_source_defined)
                goto opthelp;
            in_stdin = 1;
            break;
        }
    }
    argc = opt_num_rest();
    argv = opt_rest();
    if (*argv) {
        if (pw_source_defined)
            goto opthelp;
        pw_source_defined = 1;
        passwds = argv;
    }
    if (!usecrypt && !use1 && !useapr1) {
        usecrypt = 1;
    }
    if (usecrypt + use1 + useapr1 > 1) {
        goto opthelp;
    }
# ifdef OPENSSL_NO_DES
    if (usecrypt)
        goto opthelp;
# endif
# ifdef NO_MD5CRYPT_1
    if (use1 || useapr1)
        goto opthelp;
# endif
    if (!app_load_modules(NULL))
        goto end;
    if (infile && in_stdin) {
        BIO_printf(bio_err, "%s: Can't combine -in and -stdin\n", prog);
        goto end;
    }
    in = bio_open_default(infile, "r");
    if (in == NULL)
        goto end;
    if (usecrypt)
        pw_maxlen = 8;
    else if (use1 || useapr1)
        pw_maxlen = 256;
    if (passwds == NULL) {
        passwd_malloc_size = pw_maxlen + 2;
        passwd = passwd_malloc =
            app_malloc(passwd_malloc_size, "password buffer");
    }
    if ((in == NULL) && (passwds == NULL)) {
        static char *passwds_static[2] = { NULL, NULL };
        passwds = passwds_static;
        if (in == NULL)
            if (EVP_read_pw_string
                (passwd_malloc, passwd_malloc_size, "Password: ",
                 !(passed_salt || in_noverify)) != 0)
                goto end;
        passwds[0] = passwd_malloc;
    }
    if (in == NULL) {
        assert(passwds != NULL);
        assert(*passwds != NULL);
        do {
            passwd = *passwds++;
            if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, bio_out,
                           quiet, table, reverse, pw_maxlen, usecrypt, use1,
                           useapr1))
                goto end;
        }
        while (*passwds != NULL);
    } else
    {
        int done;
        assert(passwd != NULL);
        do {
            int r = BIO_gets(in, passwd, pw_maxlen + 1);
            if (r > 0) {
                char *c = (strchr(passwd, '\n'));
                if (c != NULL)
                    *c = 0;
                else {
                    char trash[BUFSIZ];
                    do
                        r = BIO_gets(in, trash, sizeof trash);
                    while ((r > 0) && (!strchr(trash, '\n')));
                }
                if (!do_passwd
                    (passed_salt, &salt, &salt_malloc, passwd, bio_out, quiet,
                     table, reverse, pw_maxlen, usecrypt, use1, useapr1))
                    goto end;
            }
            done = (r <= 0);
        }
        while (!done);
    }
    ret = 0;
 end:
    ERR_print_errors(bio_err);
    OPENSSL_free(salt_malloc);
    OPENSSL_free(passwd_malloc);
    BIO_free(in);
    return (ret);
}
['int passwd_main(int argc, char **argv)\n{\n    BIO *in = NULL;\n    char *infile = NULL, *salt = NULL, *passwd = NULL, **passwds = NULL;\n    char *salt_malloc = NULL, *passwd_malloc = NULL, *prog;\n    OPTION_CHOICE o;\n    int in_stdin = 0, in_noverify = 0, pw_source_defined = 0;\n    int passed_salt = 0, quiet = 0, table = 0, reverse = 0;\n    int ret = 1, usecrypt = 0, use1 = 0, useapr1 = 0;\n    size_t passwd_malloc_size = 0, pw_maxlen = 256;\n    prog = opt_init(argc, argv, passwd_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(passwd_options);\n            ret = 0;\n            goto end;\n        case OPT_IN:\n            if (pw_source_defined)\n                goto opthelp;\n            infile = opt_arg();\n            pw_source_defined = 1;\n            break;\n        case OPT_NOVERIFY:\n            in_noverify = 1;\n            break;\n        case OPT_QUIET:\n            quiet = 1;\n            break;\n        case OPT_TABLE:\n            table = 1;\n            break;\n        case OPT_REVERSE:\n            reverse = 1;\n            break;\n        case OPT_1:\n            use1 = 1;\n            break;\n        case OPT_APR1:\n            useapr1 = 1;\n            break;\n        case OPT_CRYPT:\n            usecrypt = 1;\n            break;\n        case OPT_SALT:\n            passed_salt = 1;\n            salt = opt_arg();\n            break;\n        case OPT_STDIN:\n            if (pw_source_defined)\n                goto opthelp;\n            in_stdin = 1;\n            break;\n        }\n    }\n    argc = opt_num_rest();\n    argv = opt_rest();\n    if (*argv) {\n        if (pw_source_defined)\n            goto opthelp;\n        pw_source_defined = 1;\n        passwds = argv;\n    }\n    if (!usecrypt && !use1 && !useapr1) {\n        usecrypt = 1;\n    }\n    if (usecrypt + use1 + useapr1 > 1) {\n        goto opthelp;\n    }\n# ifdef OPENSSL_NO_DES\n    if (usecrypt)\n        goto opthelp;\n# endif\n# ifdef NO_MD5CRYPT_1\n    if (use1 || useapr1)\n        goto opthelp;\n# endif\n    if (!app_load_modules(NULL))\n        goto end;\n    if (infile && in_stdin) {\n        BIO_printf(bio_err, "%s: Can\'t combine -in and -stdin\\n", prog);\n        goto end;\n    }\n    in = bio_open_default(infile, "r");\n    if (in == NULL)\n        goto end;\n    if (usecrypt)\n        pw_maxlen = 8;\n    else if (use1 || useapr1)\n        pw_maxlen = 256;\n    if (passwds == NULL) {\n        passwd_malloc_size = pw_maxlen + 2;\n        passwd = passwd_malloc =\n            app_malloc(passwd_malloc_size, "password buffer");\n    }\n    if ((in == NULL) && (passwds == NULL)) {\n        static char *passwds_static[2] = { NULL, NULL };\n        passwds = passwds_static;\n        if (in == NULL)\n            if (EVP_read_pw_string\n                (passwd_malloc, passwd_malloc_size, "Password: ",\n                 !(passed_salt || in_noverify)) != 0)\n                goto end;\n        passwds[0] = passwd_malloc;\n    }\n    if (in == NULL) {\n        assert(passwds != NULL);\n        assert(*passwds != NULL);\n        do {\n            passwd = *passwds++;\n            if (!do_passwd(passed_salt, &salt, &salt_malloc, passwd, bio_out,\n                           quiet, table, reverse, pw_maxlen, usecrypt, use1,\n                           useapr1))\n                goto end;\n        }\n        while (*passwds != NULL);\n    } else\n    {\n        int done;\n        assert(passwd != NULL);\n        do {\n            int r = BIO_gets(in, passwd, pw_maxlen + 1);\n            if (r > 0) {\n                char *c = (strchr(passwd, \'\\n\'));\n                if (c != NULL)\n                    *c = 0;\n                else {\n                    char trash[BUFSIZ];\n                    do\n                        r = BIO_gets(in, trash, sizeof trash);\n                    while ((r > 0) && (!strchr(trash, \'\\n\')));\n                }\n                if (!do_passwd\n                    (passed_salt, &salt, &salt_malloc, passwd, bio_out, quiet,\n                     table, reverse, pw_maxlen, usecrypt, use1, useapr1))\n                    goto end;\n            }\n            done = (r <= 0);\n        }\n        while (!done);\n    }\n    ret = 0;\n end:\n    ERR_print_errors(bio_err);\n    OPENSSL_free(salt_malloc);\n    OPENSSL_free(passwd_malloc);\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}', 'int app_load_modules(const CONF *config)\n{\n    CONF *to_free = NULL;\n    if (config == NULL)\n\tconfig = to_free = app_load_config_quiet(default_config_file);\n    if (config == NULL)\n\treturn 1;\n    if (CONF_modules_load(config, NULL, 0) <= 0) {\n        BIO_printf(bio_err, "Error configuring OpenSSL modules\\n");\n        ERR_print_errors(bio_err);\n        NCONF_free(to_free);\n        return 0;\n    }\n    NCONF_free(to_free);\n    return 1;\n}', 'BIO *bio_open_default(const char *filename, const char *mode)\n{\n    return bio_open_default_(filename, mode, 0);\n}', 'static BIO *bio_open_default_(const char *filename, const char *mode, int quiet)\n{\n    BIO *ret;\n    if (filename == NULL || strcmp(filename, "-") == 0) {\n        ret = *mode == \'r\' ? dup_bio_in() : dup_bio_out();\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, mode);\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,\n                   *mode == \'r\' ? "reading" : "writing", strerror(errno));\n    }\n    ERR_print_errors(bio_err);\n    return NULL;\n}', 'BIO *dup_bio_in(void)\n{\n    return BIO_new_fp(stdin, BIO_NOCLOSE | BIO_FP_TEXT);\n}']