summaryrefslogtreecommitdiff
path: root/lib/lanplus/lanplus_crypt_impl.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-30 16:52:34 +0200
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-03-30 16:52:34 +0200
commit631fa5250443f5441549bf3184830bc34b0c042e (patch)
tree78fbc8dcfbe36b7f3499c4dc5c3017435d6fb2a1 /lib/lanplus/lanplus_crypt_impl.c
parent09863e30b4f27257be0299024d5a0de255f8ea84 (diff)
parentdf5450149923efb0366001947c1456ed442bc4bb (diff)
Merge branch 'release/3.0.8-1'3.0.8-1
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*/