summaryrefslogtreecommitdiff
path: root/lib/lanplus
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2018-01-14 19:52:45 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2018-01-14 19:52:45 +0100
commitd5cdf594f2678cf690b802fbf4eb687dd9d98c4f (patch)
treee1a4a0b0aee0de7d5f8a03afa444b2470ebdb132 /lib/lanplus
parent4b28a392fa890390755f58e0755ab56e8edaa295 (diff)
New upstream version 3.0.8upstream/3.0.8
Diffstat (limited to 'lib/lanplus')
-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*/