Fix warnings about ignoring fgets return value
[openssl.git] / apps / openssl.c
index dcfb796176c57c82ca4618d8add12735323ab7b6..851e63973581fc191c42ad418154769dae01ecc5 100644 (file)
@@ -272,9 +272,21 @@ int main(int Argc, char *Argv[])
        i=NCONF_load(config,p,&errline);
        if (i == 0)
                {
-               NCONF_free(config);
-               config = NULL;
-               ERR_clear_error();
+               if (ERR_GET_REASON(ERR_peek_last_error())
+                   == CONF_R_NO_SUCH_FILE)
+                       {
+                       BIO_printf(bio_err,
+                                  "WARNING: can't open config file: %s\n",p);
+                       ERR_clear_error();
+                       NCONF_free(config);
+                       config = NULL;
+                       }
+               else
+                       {
+                       ERR_print_errors(bio_err);
+                       NCONF_free(config);
+                       exit(1);
+                       }
                }
 
        prog=prog_init();
@@ -318,7 +330,8 @@ int main(int Argc, char *Argv[])
                        else    prompt="OpenSSL> ";
                        fputs(prompt,stdout);
                        fflush(stdout);
-                       fgets(p,n,stdin);
+                       if (!fgets(p,n,stdin))
+                               goto end;
                        if (p[0] == '\0') goto end;
                        i=strlen(p);
                        if (i <= 1) break;
@@ -380,6 +393,21 @@ static int do_cmd(LHASH_OF(FUNCTION) *prog, int argc, char *argv[])
                { ret=0; goto end; }
        f.name=argv[0];
        fp=lh_FUNCTION_retrieve(prog,&f);
+       if (fp == NULL)
+               {
+               if (EVP_get_digestbyname(argv[0]))
+                       {
+                       f.type = FUNC_TYPE_MD;
+                       f.func = dgst_main;
+                       fp = &f;
+                       }
+               else if (EVP_get_cipherbyname(argv[0]))
+                       {
+                       f.type = FUNC_TYPE_CIPHER;
+                       f.func = enc_main;
+                       fp = &f;
+                       }
+               }
        if (fp != NULL)
                {
                ret=fp->func(argc,argv);
@@ -618,7 +646,7 @@ static LHASH_OF(FUNCTION) *prog_init(void)
                return(NULL);
 
        for (f=functions; f->name != NULL; f++)
-               lh_FUNCTION_insert(ret,f);
+               (void)lh_FUNCTION_insert(ret,f);
        return(ret);
        }