strsep implementation to allow the file to compile on non-BSD systems
[openssl.git] / crypto / rand / randfile.c
index ec137c4e31db1f595c2040a58295764abf1d2c84..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>
 
@@ -194,7 +194,7 @@ err:
        return (rand_err ? -1 : ret);
        }
 
-const char *RAND_file_name(char *buf, int size)
+const char *RAND_file_name(char *buf, size_t size)
        {
        char *s=NULL;
        char *ret=NULL;
@@ -211,6 +211,12 @@ const char *RAND_file_name(char *buf, int 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, int size)
                        strcat(buf,RFILE);
                        ret=buf;
                        }
-                 else
+               else
                        buf[0] = '\0'; /* no file name */
                }
        return(ret);