diff options
author | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-24 16:56:03 +0000 |
---|---|---|
committer | kuchhal@chromium.org <kuchhal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-06-24 16:56:03 +0000 |
commit | 6e620b2814702b534df0468e59365d35dc543d00 (patch) | |
tree | 96104e8b0f035aabd463b4028c28c2322516e0ee /chrome/installer/mini_installer/mini_installer.cc | |
parent | 8df44a01ec210a3e0c04191fb34b392727017a2c (diff) | |
download | chromium_src-6e620b2814702b534df0468e59365d35dc543d00.zip chromium_src-6e620b2814702b534df0468e59365d35dc543d00.tar.gz chromium_src-6e620b2814702b534df0468e59365d35dc543d00.tar.bz2 |
Fix the code that writes magic string to the registry.
BUG=15095
Review URL: http://codereview.chromium.org/146063
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@19133 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/installer/mini_installer/mini_installer.cc')
-rw-r--r-- | chrome/installer/mini_installer/mini_installer.cc | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/chrome/installer/mini_installer/mini_installer.cc b/chrome/installer/mini_installer/mini_installer.cc index 84c7d94..09df494 100644 --- a/chrome/installer/mini_installer/mini_installer.cc +++ b/chrome/installer/mini_installer/mini_installer.cc @@ -154,14 +154,24 @@ void SetFullInstallerFlag(HKEY root_key) { wchar_t value[128]; size_t size = _countof(value); - if ((::RegQueryValueEx(key, kApRegistryValueName, NULL, NULL, - reinterpret_cast<LPBYTE>(value), - reinterpret_cast<LPDWORD>(&size)) == ERROR_SUCCESS) && - (!StrEndsWith(value, kFullInstallerSuffix)) && - (SafeStrCat(value, size, kFullInstallerSuffix))) { - ::RegSetValueEx(key, kApRegistryValueName, 0, REG_SZ, - reinterpret_cast<LPBYTE>(value), - lstrlen(value) * sizeof(wchar_t)); + size_t buf_size = size; + LONG ret = ::RegQueryValueEx(key, kApRegistryValueName, NULL, NULL, + reinterpret_cast<LPBYTE>(value), + reinterpret_cast<LPDWORD>(&size)); + + // The conditions below are handling two cases: + // 1. When ap key is present, we want to make sure it doesn't already end + // in -full and then append -full to it. + // 2. When ap key is missing, we are going to create it with value -full. + if ((ret == ERROR_SUCCESS) || (ret == ERROR_FILE_NOT_FOUND)) { + if (ret == ERROR_FILE_NOT_FOUND) + value[0] = L'\0'; + + if (!StrEndsWith(value, kFullInstallerSuffix) && + (SafeStrCat(value, buf_size, kFullInstallerSuffix))) + ::RegSetValueEx(key, kApRegistryValueName, 0, REG_SZ, + reinterpret_cast<LPBYTE>(value), + lstrlen(value) * sizeof(wchar_t)); } ::RegCloseKey(key); |