From 3485928ffe1174f1c71c6438be867a5e0fc4616a Mon Sep 17 00:00:00 2001 From: "rogerta@google.com" Date: Thu, 9 Sep 2010 23:53:00 +0000 Subject: [PATCH 1/2] Creating a branch for changes needed specifically for chrome 6.0.472.x --- DEPS | 2 +- win/lib/financial_ping.cc | 4 ++-- win/lib/machine_deal.cc | 13 ++----------- win/lib/string_utils.cc | 5 ++--- 4 files changed, 7 insertions(+), 17 deletions(-) diff --git a/DEPS b/DEPS index 66f155b..620009b 100644 --- a/DEPS +++ b/DEPS @@ -3,7 +3,7 @@ # found in the COPYING file. vars = { - "chrev": "@57045" + "chrev": "@56144" } deps = { diff --git a/win/lib/financial_ping.cc b/win/lib/financial_ping.cc index 2ab4efb..ba1fccd 100644 --- a/win/lib/financial_ping.cc +++ b/win/lib/financial_ping.cc @@ -212,7 +212,7 @@ bool FinancialPing::IsPingTime(Product product, const wchar_t* sid, StringAppendF(&key_location, L"%ls\\%ls", kLibKeyName, kPingTimesSubkeyName); uint64 last_ping; - DWORD size = sizeof(last_ping); + DWORD size; DWORD type; RegKey key(user_key.Get(), key_location.c_str(), KEY_READ); if (!key.ReadValue(GetProductName(product), &last_ping, &size, &type)) @@ -277,7 +277,7 @@ bool FinancialPing::ClearLastPingTime(Product product, const wchar_t* sid) { // Verify deletion. uint64 value; DWORD size = sizeof(value); - if (key.ReadValue(value_name, &value, &size, NULL)) { + if (key.ReadValue(value_name, &value, &size)) { ASSERT_STRING("FinancialPing::ClearLastPingTime: Failed to delete value."); return false; } diff --git a/win/lib/machine_deal.cc b/win/lib/machine_deal.cc index 1ac589d..cb10060 100644 --- a/win/lib/machine_deal.cc +++ b/win/lib/machine_deal.cc @@ -291,7 +291,7 @@ bool MachineDealCode::Clear() { // Verify deletion. wchar_t dcc[kMaxDccLength + 1]; DWORD dcc_size = arraysize(dcc); - if (dcc_key.ReadValue(kDccValueName, dcc, &dcc_size, NULL)) { + if (dcc_key.ReadValue(kDccValueName, dcc, &dcc_size)) { ASSERT_STRING("MachineDealCode::Clear: Could not delete the DCC value."); return false; } @@ -418,17 +418,8 @@ bool MachineDealCode::GetMachineId(std::wstring* machine_id) { // Hash the SID. if (!sid_string.empty()) { - // In order to be compatible with the old version of RLZ, the hash of the - // SID must be done with all the original bytes from the unicode string. - // However, the chromebase SHA1 hash function takes only an std::string as - // input, so the unicode string needs to be converted to std::string - // "as is". - size_t byte_count = sid_string.size() * sizeof(std::wstring::value_type); - const char* buffer = reinterpret_cast(sid_string.c_str()); - std::string sid_string_buffer(buffer, byte_count); - // Note that digest can have embedded nulls. - std::string digest(base::SHA1HashString(sid_string_buffer)); + std::string digest(base::SHA1HashString(WideToASCII(sid_string))); VERIFY(digest.size() == base::SHA1_LENGTH); std::copy(digest.begin(), digest.end(), id_binary.begin()); } diff --git a/win/lib/string_utils.cc b/win/lib/string_utils.cc index 31dde7b..ebbe9f3 100644 --- a/win/lib/string_utils.cc +++ b/win/lib/string_utils.cc @@ -7,7 +7,7 @@ #include "rlz/win/lib/string_utils.h" #include "base/registry.h" -#include "base/utf_string_conversions.h" +#include "base/string_util.h" #include "rlz/win/lib/assert.h" namespace rlz_lib { @@ -105,8 +105,7 @@ bool RegKeyReadValue(RegKey& key, const wchar_t* name, return false; } - // Note that RLZ string are always ASCII by design. - strncpy(value, WideToUTF8(value_string).c_str(), *value_size); + strncpy(value, WideToASCII(value_string).c_str(), *value_size); value[*value_size - 1] = 0; return true; } From 04ac244ff78cef390d6b5518fde63be8e4f3e9db Mon Sep 17 00:00:00 2001 From: "rogerta@google.com" Date: Fri, 10 Sep 2010 00:15:54 +0000 Subject: [PATCH 2/2] Backpatching r17 from trunk to chrome472 branch --- win/lib/machine_deal.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/win/lib/machine_deal.cc b/win/lib/machine_deal.cc index cb10060..5c76a47 100644 --- a/win/lib/machine_deal.cc +++ b/win/lib/machine_deal.cc @@ -418,8 +418,17 @@ bool MachineDealCode::GetMachineId(std::wstring* machine_id) { // Hash the SID. if (!sid_string.empty()) { + // In order to be compatible with the old version of RLZ, the hash of the + // SID must be done with all the original bytes from the unicode string. + // However, the chromebase SHA1 hash function takes only an std::string as + // input, so the unicode string needs to be converted to std::string + // "as is". + size_t byte_count = sid_string.size() * sizeof(std::wstring::value_type); + const char* buffer = reinterpret_cast(sid_string.c_str()); + std::string sid_string_buffer(buffer, byte_count); + // Note that digest can have embedded nulls. - std::string digest(base::SHA1HashString(WideToASCII(sid_string))); + std::string digest(base::SHA1HashString(sid_string_buffer)); VERIFY(digest.size() == base::SHA1_LENGTH); std::copy(digest.begin(), digest.end(), id_binary.begin()); }