summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-18 00:32:40 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-18 00:32:40 +0000
commit222f0840463e0681181b374f8734153d9f23443d (patch)
treef113b18ab2a1d1c5cab291d26301c92c2988c361
parent093e7eba18610c1b154dc0282ef572626f7d34f9 (diff)
downloadopenvpn-222f0840463e0681181b374f8734153d9f23443d.zip
openvpn-222f0840463e0681181b374f8734153d9f23443d.tar.gz
openvpn-222f0840463e0681181b374f8734153d9f23443d.tar.xz
Modified create_temp_filename to create unpredictable
filenames. git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3074 e7ae566f-a301-0410-adde-c780ea21d3b5
-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.
*/