From d5cdf594f2678cf690b802fbf4eb687dd9d98c4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Sun, 14 Jan 2018 19:52:45 +0100 Subject: New upstream version 3.0.8 --- lib/lanplus/lanplus_crypt_impl.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'lib/lanplus/lanplus_crypt_impl.c') 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 #include - +#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*/ -- cgit v1.2.3