vpaes-x86[_64]*.pl: fix typo.
[openssl.git] / apps / enc.c
index a64c654d4d2b37d8893bdbc05636b478932e60c5..076225c4cb560ca8dd81160f54546a9562a713e5 100644 (file)
@@ -101,9 +101,6 @@ int MAIN(int, char **);
 
 int MAIN(int argc, char **argv)
        {
-#ifndef OPENSSL_NO_ENGINE
-       ENGINE *e = NULL;
-#endif
        static const char magic[]="Salted__";
        char mbuf[sizeof magic-1];
        char *strbuf=NULL;
@@ -243,7 +240,12 @@ int MAIN(int argc, char **argv)
                                goto bad;
                                }
                        buf[0]='\0';
-                       fgets(buf,sizeof buf,infile);
+                       if (!fgets(buf,sizeof buf,infile))
+                               {
+                               BIO_printf(bio_err,"unable to read key from '%s'\n",
+                                       file);
+                               goto bad;
+                               }
                        fclose(infile);
                        i=strlen(buf);
                        if ((i > 0) &&
@@ -323,7 +325,7 @@ bad:
                }
 
 #ifndef OPENSSL_NO_ENGINE
-        e = setup_engine(bio_err, engine, 0);
+        setup_engine(bio_err, engine, 0);
 #endif
 
        if (md && (dgst=EVP_get_digestbyname(md)) == NULL)
@@ -391,8 +393,10 @@ bad:
 
        if (inf == NULL)
                {
+#ifndef OPENSSL_NO_SETVBUF_IONBF
                if (bufsize != NULL)
                        setvbuf(stdin, (char *)NULL, _IONBF, 0);
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
                BIO_set_fp(in,stdin,BIO_NOCLOSE);
                }
        else
@@ -445,8 +449,10 @@ bad:
        if (outf == NULL)
                {
                BIO_set_fp(out,stdout,BIO_NOCLOSE);
+#ifndef OPENSSL_NO_SETVBUF_IONBF
                if (bufsize != NULL)
                        setvbuf(stdout, (char *)NULL, _IONBF, 0);
+#endif /* ndef OPENSSL_NO_SETVBUF_IONBF */
 #ifdef OPENSSL_SYS_VMS
                {
                BIO *tmpbio = BIO_new(BIO_f_linebuffer());
@@ -560,7 +566,8 @@ bad:
                        BIO_printf(bio_err,"invalid hex iv value\n");
                        goto end;
                        }
-               if ((hiv == NULL) && (str == NULL))
+               if ((hiv == NULL) && (str == NULL)
+                   && EVP_CIPHER_iv_length(cipher) != 0)
                        {
                        /* No IV was explicitly set and no IV was generated
                         * during EVP_BytesToKey. Hence the IV is undefined,