Some platforms (most notably Windows) do not have a $HOME by default.
authorRichard Levitte <levitte@openssl.org>
Thu, 3 May 2001 07:50:11 +0000 (07:50 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 3 May 2001 07:50:11 +0000 (07:50 +0000)
For those, unless the environment variables RANDFILE or HOME are
defined (the default case!), RAND_file_name() will return NULL.
This change adds a default HOME for those platforms.

To add a default HOME for any platform, just define DEFAULT_HOME in
the proper place, wrapped in appropriate #ifdef..#endif, in e_os.h.

crypto/rand/randfile.c
e_os.h

index 8623e13e18ee0dc4e27eedaa286f26afde190a8b..982074c465ba4547a61d969073b0e21e5ba4e9a1 100644 (file)
@@ -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);
diff --git a/e_os.h b/e_os.h
index 6cef40f5a5d37b513c88079a4a8893c018671ee7..08410f9eb40104db5f0ca323e7c60020c0f1766c 100644 (file)
--- a/e_os.h
+++ b/e_os.h
@@ -230,6 +230,7 @@ extern "C" {
 #  define SSLEAY_CONF  OPENSSL_CONF
 #  define NUL_DEV      "nul"
 #  define RFILE                ".rnd"
+#  define DEFAULT_HOME  "C:"
 
 #else /* The non-microsoft world world */