Correct serious bug in AES-CBC decryption when the message length isn't
[openssl.git] / crypto / des / read_pwd.c
index dc848f5af3b7f0bff3d6e23ca2f9fb516f159bed..ce5fa00a37a42fdf8d38bb6e36e2cb720744e5df 100644 (file)
@@ -56,8 +56,8 @@
  * [including the GNU Public Licence.]
  */
 
+#include <openssl/e_os2.h>
 #if !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WIN32)
-#include <openssl/opensslconf.h>
 #ifdef OPENSSL_UNISTD
 # include OPENSSL_UNISTD
 #else
 
 #ifdef WIN_CONSOLE_BUG
 #include <windows.h>
+#ifndef OPENSSL_SYS_WINCE
 #include <wincon.h>
 #endif
+#endif
 
 
 /* There are 5 types of terminal interface supported,
 #define SGTTY
 #endif
 
+#if defined(OPENSSL_SYS_VXWORKS)
+#undef TERMIOS
+#undef TERMIO
+#undef SGTTY
+#endif
+
 #ifdef TERMIOS
 #include <termios.h>
 #define TTY_STRUCT             struct termios
 #include <sys/ioctl.h>
 #endif
 
-#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__)
+#if defined(OPENSSL_SYS_MSDOS) && !defined(__CYGWIN32__) && !defined(OPENSSL_SYS_WINCE)
 #include <conio.h>
 #define fgets(a,b,c) noecho_fgets(a,b,c)
 #endif
@@ -212,11 +220,29 @@ int des_read_pw_string(char *buf, int length, const char *prompt,
        int ret;
 
        ret=des_read_pw(buf,buff,(length>BUFSIZ)?BUFSIZ:length,prompt,verify);
-       memset(buff,0,BUFSIZ);
+       OPENSSL_cleanse(buff,BUFSIZ);
        return(ret);
        }
 
-#ifndef OPENSSL_SYS_WIN16
+#ifdef OPENSSL_SYS_WINCE
+
+int des_read_pw(char *buf, char *buff, int size, const char *prompt, int verify)
+       { 
+       memset(buf,0,size);
+       memset(buff,0,size);
+       return(0);
+       }
+
+#elif defined(OPENSSL_SYS_WIN16)
+
+int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
+       { 
+       memset(buf,0,size);
+       memset(buff,0,size);
+       return(0);
+       }
+
+#else /* !OPENSSL_SYS_WINCE && !OPENSSL_SYS_WIN16 */
 
 static void read_till_nl(FILE *in)
        {
@@ -240,7 +266,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
        long status;
        unsigned short channel = 0;
 #else
-#ifndef OPENSSL_SYS_MSDOS
+#if !defined(OPENSSL_SYS_MSDOS) || defined(__DJGPP__)
        TTY_STRUCT tty_orig,tty_new;
 #endif
 #endif
@@ -268,7 +294,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
 #ifdef OPENSSL_SYS_MSDOS
        if ((tty=fopen("con","r")) == NULL)
                tty=stdin;
-#elif defined(MAC_OS_pre_X)
+#elif defined(MAC_OS_pre_X) || defined(OPENSSL_SYS_VXWORKS)
        tty=stdin;
 #else
 #ifndef OPENSSL_SYS_MPE
@@ -366,7 +392,7 @@ int des_read_pw(char *buf, char *buff, int size, const char *prompt,
 
 error:
        fprintf(stderr,"\n");
-#ifdef DEBUG
+#if 0
        perror("fgets(tty)");
 #endif
        /* What can we do if there is an error? */
@@ -387,17 +413,6 @@ error:
        return(!ok);
        }
 
-#else /* OPENSSL_SYS_WIN16 */
-
-int des_read_pw(char *buf, char *buff, int size, char *prompt, int verify)
-       { 
-       memset(buf,0,size);
-       memset(buff,0,size);
-       return(0);
-       }
-
-#endif
-
 static void pushsig(void)
        {
        int i;
@@ -460,7 +475,7 @@ static void recsig(int i)
 #endif
        }
 
-#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_WIN16)
+#ifdef OPENSSL_SYS_MSDOS
 static int noecho_fgets(char *buf, int size, FILE *tty)
        {
        int i;
@@ -503,3 +518,4 @@ static int noecho_fgets(char *buf, int size, FILE *tty)
        return(strlen(buf));
        }
 #endif
+#endif /* !OPENSSL_SYS_WINCE && !WIN16 */