Chromium Code Reviews| 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..b46d1c3a4dfcc928b6f543b6031a27bca8d753a2 100644 |
| --- a/components/sync/engine_impl/commit.cc |
| +++ b/components/sync/engine_impl/commit.cc |
| @@ -27,8 +27,29 @@ 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; |
| + |
| +const char kLegalCharacters[] = |
| + "abcdefghijklmnopqrstuvwxyz" |
| + "ABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| + "0123456789" |
| + " .-,/\\:;"; |
| + |
| +const int first_char_index = 0; |
| +const int last_char_index = sizeof(kLegalCharacters) - 2; |
| + |
| +std::string RandomString(int length) { |
|
maxbogue
2017/01/20 01:24:56
I was poking around trying to understand RandInt a
Gang Wu
2017/01/20 07:46:56
Done.
|
| + std::string random; |
| + random.reserve(length); |
| + for (int i = 0; i < length; ++i) { |
| + random.push_back( |
| + kLegalCharacters[base::RandInt(first_char_index, last_char_index)]); |
| + } |
| + |
| + return random; |
| } |
| +} // namespace |
| + |
| Commit::Commit(ContributionMap contributions, |
| const sync_pb::ClientToServerMessage& message, |
| ExtensionsActivity::Records extensions_activity_buffer) |
| @@ -69,7 +90,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(RandomString(kPaddingSize)); |
| } |
| // Set extensions activity if bookmark commits are present. |