]> git.ipfire.org Git - thirdparty/openvpn.git/commitdiff
Modified create_temp_filename to create unpredictable
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Fri, 18 Jul 2008 00:32:40 +0000 (00:32 +0000)
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>
Fri, 18 Jul 2008 00:32:40 +0000 (00:32 +0000)
filenames.

git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3074 e7ae566f-a301-0410-adde-c780ea21d3b5

misc.c

diff --git a/misc.c b/misc.c
index 8eff3d7f1b3ebaf7a424a921db78f3a81de5ab5b..97e80496749e976de83ac2fd9bab7a17a4aaf1de 100644 (file)
--- 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.
  */