Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2878)

Unified Diff: base/file_util_win.cc

Issue 15479003: base: Fix file_util_win.cc temp file random name generation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/file_util_win.cc
diff --git a/base/file_util_win.cc b/base/file_util_win.cc
index b9e9d62cedd797a63fc779a4f0968133614fdb09..5d5dfdf405d136155c48c7a9cc426873edbdb757 100644
--- a/base/file_util_win.cc
+++ b/base/file_util_win.cc
@@ -18,6 +18,7 @@
#include "base/logging.h"
#include "base/metrics/histogram.h"
#include "base/process_util.h"
+#include "base/rand_util.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
@@ -371,7 +372,6 @@ bool CreateTemporaryDirInDir(const FilePath& base_dir,
base::ThreadRestrictions::AssertIOAllowed();
FilePath path_to_create;
- srand(static_cast<uint32>(time(NULL)));
for (int count = 0; count < 50; ++count) {
// Try create a new temporary directory with random generated name. If
@@ -380,7 +380,7 @@ bool CreateTemporaryDirInDir(const FilePath& base_dir,
new_dir_name.assign(prefix);
new_dir_name.append(base::IntToString16(::base::GetCurrentProcId()));
new_dir_name.push_back('_');
- new_dir_name.append(base::IntToString16(rand() % kint16max));
+ new_dir_name.append(base::IntToString16(base::RandInt(0, kint16max)));
path_to_create = base_dir.Append(new_dir_name);
if (::CreateDirectory(path_to_create.value().c_str(), NULL)) {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698