Some platforms (most notably Windows) do not have a $HOME by default.
[openssl.git] / crypto / rand / randfile.c
index 41dd1d70a4f240ebbf1396c745071d2f69f0e9ee..982074c465ba4547a61d969073b0e21e5ba4e9a1 100644 (file)
@@ -61,7 +61,7 @@
 #include <stdlib.h>
 #include <string.h>
 
-#include "openssl/e_os.h"
+#include "e_os.h"
 #include <openssl/crypto.h>
 #include <openssl/rand.h>
 
@@ -211,6 +211,12 @@ const char *RAND_file_name(char *buf, size_t size)
                {
                if (OPENSSL_issetugid() == 0)
                        s=getenv("HOME");
+#ifdef DEFAULT_HOME
+               if (s == NULL)
+                       {
+                       s = DEFAULT_HOME;
+                       }
+#endif
                if (s != NULL && (strlen(s)+strlen(RFILE)+2 < size))
                        {
                        strcpy(buf,s);
@@ -220,7 +226,7 @@ const char *RAND_file_name(char *buf, size_t size)
                        strcat(buf,RFILE);
                        ret=buf;
                        }
-                 else
+               else
                        buf[0] = '\0'; /* no file name */
                }
        return(ret);