summaryrefslogtreecommitdiff
path: root/lib/lanplus/lanplus_crypt_impl.c
diff options
context:
space:
mode:
authorJörg Frings-Fürst <debian@jff-webhosting.net>2015-11-06 01:42:41 +0100
committerJörg Frings-Fürst <debian@jff-webhosting.net>2015-11-06 01:42:41 +0100
commitee6c7128ed0d58cb1812049463a13bba9cfb31b7 (patch)
tree39b80b4d29c70262a7a6f3443e4acb6bd592b287 /lib/lanplus/lanplus_crypt_impl.c
parentb18f5bf2db0fba2e7e539f68645836036d940d26 (diff)
Imported Upstream version 2.9.7upstream/2.9.7
Diffstat (limited to 'lib/lanplus/lanplus_crypt_impl.c')
-rw-r--r--lib/lanplus/lanplus_crypt_impl.c21
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/lanplus/lanplus_crypt_impl.c b/lib/lanplus/lanplus_crypt_impl.c
index 3f9679e..d12ad9c 100644
--- a/lib/lanplus/lanplus_crypt_impl.c
+++ b/lib/lanplus/lanplus_crypt_impl.c
@@ -61,13 +61,20 @@ int lanplus_seed_prng(uint32_t bytes)
static FILE *fp = NULL;
size_t i;
randfile = RAND_file_name(buffer, sizeof buffer); /* usu C:\.rnd */
- if ((randfile != NULL) && (fp == NULL)) {
- /*first time, so open/create file*/
- fp = fopen(randfile,"w"); /*create the randfile*/
- if (fp != NULL) {
- i = fwrite(" \n",2,1,fp);
- fclose(fp);
- }
+ if ((randfile != NULL) && (fp == NULL)) {
+ fp = fopen(randfile,"r"); /*check the randfile*/
+ if (fp == NULL) { /*does not exist, create it*/
+ /*first time, so open/create file*/
+ fp = fopen(randfile,"w"); /*create the randfile*/
+ if (fp != NULL) {
+ i = fwrite(" \n",2,1,fp);
+ fclose(fp);
+ } else {
+ printf("seed_prng: cannot create %s file\n",randfile);
+ }
+ } else { /*file opened, so close it*/
+ fclose(fp);
+ }
}
if (verbose > 0)
printf("seed_prng: RAND_file_name = %s, fp=%p\n",randfile,fp);