When only the key is given to "enc", the IV is undefined
(found by Andy Brown <logic@warthog.com>).
diff --git a/apps/enc.c b/apps/enc.c
index 49cae75..3c72d05 100644
--- a/apps/enc.c
+++ b/apps/enc.c
@@ -488,6 +488,14 @@
 			BIO_printf(bio_err,"invalid hex iv value\n");
 			goto end;
 			}
+		if ((hiv == NULL) && (str == NULL))
+			{
+			/* No IV was explicitly set and no IV was generated
+			 * during EVP_BytesToKey. Hence the IV is undefined,
+			 * making correct decryption impossible. */
+			BIO_printf(bio_err, "iv undefined\n");
+			goto end;
+			}
 		if ((hkey != NULL) && !set_hex(hkey,key,sizeof key))
 			{
 			BIO_printf(bio_err,"invalid hex key value\n");