diff options
author | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-18 00:32:40 +0000 |
---|---|---|
committer | james <james@e7ae566f-a301-0410-adde-c780ea21d3b5> | 2008-07-18 00:32:40 +0000 |
commit | 222f0840463e0681181b374f8734153d9f23443d (patch) | |
tree | f113b18ab2a1d1c5cab291d26301c92c2988c361 | |
parent | Previously, OpenVPN might log a client's auth-user-pass (diff) | |
download | 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.c | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -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. */ |