Make sure memset() is properly declared.
[openssl.git] / crypto / ui / ui_compat.c
index fd8e004c107c5a32902008cc5cd279eb29dd12b9..701c07c181c0bb0af5d9b57ccf964f6b414876ea 100644 (file)
@@ -57,6 +57,7 @@
  * [including the GNU Public Licence.]
  */
 
+#include <string.h>
 #include <openssl/ui_compat.h>
 
 #ifndef OPENSSL_NO_DES
@@ -98,13 +99,19 @@ int des_read_pw_string(char *buf,int length,const char *prompt,int verify)
 
 int des_read_pw(char *buf,char *buff,int size,const char *prompt,int verify)
        {
+       int ok = 0;
        UI *ui;
 
        ui = UI_new();
-       UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1);
-       if (verify)
-               UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,buf);
-       ok=UI_process(ui);
-       UI_free(ui);
+       if (ui)
+               {
+               ok = UI_add_input_string(ui,prompt,0,buf,0,BUFSIZ-1);
+               if (ok == 0 && verify)
+                       ok = UI_add_verify_string(ui,prompt,0,buff,0,BUFSIZ-1,
+                               buf);
+               if (ok == 0)
+                       ok=UI_process(ui);
+               UI_free(ui);
+               }
        return(ok);
        }