summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--misc.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/misc.c b/misc.c
index 8eff3d7..97e8049 100644
--- a/misc.c
+++ b/misc.c
@@ -1086,6 +1086,8 @@ test_file (const char *filename)
return ret;
}
+#ifdef USE_CRYPTO
+
/* create a temporary filename in directory */
const char *
create_temp_filename (const char *directory, const char *prefix, struct gc_arena *gc)
@@ -1097,15 +1099,20 @@ create_temp_filename (const char *directory, const char *prefix, struct gc_arena
++counter;
mutex_unlock_static (L_CREATE_TEMP);
- buf_printf (&fname, PACKAGE "_%s_%u_%u_%u.tmp",
- prefix,
- openvpn_getpid (),
- counter,
- (unsigned int)now);
+ {
+ uint8_t rndbytes[16];
+ const char *rndstr;
+
+ prng_bytes (rndbytes, sizeof (rndbytes));
+ rndstr = format_hex_ex (rndbytes, sizeof (rndbytes), 40, 0, NULL, gc);
+ buf_printf (&fname, PACKAGE "_%s_%s.tmp", prefix, rndstr);
+ }
return gen_path (directory, BSTR (&fname), gc);
}
+#endif
+
/*
* Put a directory and filename together.
*/