oops, revert unrelated changes
[openssl.git] / apps / enc.c
index 53de51ad72189a0aecb16e3d96c02079a22896a7..8c5527783b22550e6648065d4a7645fbef1a03ea 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());
@@ -543,9 +549,13 @@ bad:
                                sptr = salt;
                        }
 
-                       EVP_BytesToKey(cipher,dgst,sptr,
-                               (unsigned char *)str,
-                               strlen(str),1,key,iv);
+                       if (!EVP_BytesToKey(cipher,dgst,sptr,
+                                           (unsigned char *)str,
+                                           strlen(str),1,key,iv))
+                               {
+                               BIO_printf(bio_err, "EVP_BytesToKey failed\n");
+                               goto end;
+                               }
                        /* zero the complete buffer or the string
                         * passed from the command line
                         * bug picked up by