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

Unified Diff: components/sync/engine_impl/commit.cc

Issue 2637173004: [Sync] Do not use base::RandBytesAsString to generate random string (Closed)
Patch Set: change the way to random string Created 3 years, 11 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: components/sync/engine_impl/commit.cc
diff --git a/components/sync/engine_impl/commit.cc b/components/sync/engine_impl/commit.cc
index 877ba4ca07983cf5524449ee07669a1ca2a81059..2c9485080023fe7bac84f37a608c42608cc13369 100644
--- a/components/sync/engine_impl/commit.cc
+++ b/components/sync/engine_impl/commit.cc
@@ -27,8 +27,19 @@ namespace {
// because it is not too large (to hurt performance and compression ratio), but
// it is not too small to easily be canceled out using statistical analysis.
const size_t kPaddingSize = 256;
+
+std::string RandASCIIString(size_t length) {
+ std::string result;
+ const int kMin = static_cast<int>(' ');
+ const int kMax = static_cast<int>('~');
+ result.reserve(length);
+ for (size_t i = 0; i < length; ++i)
+ result.push_back(static_cast<char>(base::RandInt(kMin, kMax)));
+ return result;
}
+} // namespace
+
Commit::Commit(ContributionMap contributions,
const sync_pb::ClientToServerMessage& message,
ExtensionsActivity::Records extensions_activity_buffer)
@@ -69,7 +80,7 @@ Commit* Commit::Init(ModelTypeSet requested_types,
// Set padding to mitigate CRIME attack.
if (base::FeatureList::IsEnabled(syncer::kSyncClientToServerCompression)) {
- commit_message->set_padding(base::RandBytesAsString(kPaddingSize));
+ commit_message->set_padding(RandASCIIString(kPaddingSize));
}
// Set extensions activity if bookmark commits are present.
« 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