summaryrefslogtreecommitdiff
path: root/lib/lanplus/lanplus_crypt_impl.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/lanplus/lanplus_crypt_impl.c')
-rw-r--r--lib/lanplus/lanplus_crypt_impl.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/lanplus/lanplus_crypt_impl.c b/lib/lanplus/lanplus_crypt_impl.c
index 1daf230..389a436 100644
--- a/lib/lanplus/lanplus_crypt_impl.c
+++ b/lib/lanplus/lanplus_crypt_impl.c
@@ -41,7 +41,27 @@
#include <openssl/err.h>
#include <assert.h>
-
+#ifdef WIN32
+/* win_rand_filename
+ Custom RAND_file_name routine to use better path than C:\
+ Use: %USERPROFILE%, %HOME%, %HOMEPATH%,
+ USERPROFILE=C:\Users\acress
+ HOMEDRIVE=C:
+ HOMEPATH=\Users\acress
+ */
+char *win_rand_filename(char *buffer, int bufsz)
+{
+ char *root = "C:\\";
+ char *envpath = NULL;
+
+ envpath = getenv("USERPROFILE");
+ if ((envpath == NULL) || (envpath[0] == '\0')) {
+ envpath = root;
+ }
+ snprintf(buffer,bufsz,"%s\\.rnd",envpath);
+ return(buffer);
+}
+#endif
/*
* lanplus_seed_prng
@@ -60,7 +80,8 @@ int lanplus_seed_prng(uint32_t bytes)
char buffer[200];
static FILE *fp = NULL;
size_t i;
- randfile = RAND_file_name(buffer, sizeof buffer); /* usu C:\.rnd */
+ // randfile = RAND_file_name(buffer, sizeof buffer); /* usu C:\.rnd */
+ randfile = win_rand_filename(buffer, sizeof buffer);
if ((randfile != NULL) && (fp == NULL)) {
fp = fopen(randfile,"r"); /*check the randfile*/
if (fp == NULL) { /*does not exist, create it*/