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

Side by Side Diff: chrome/installer/util/shell_util.cc

Issue 10703147: Convert SID string to ASCII before taking md5 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 // 4 //
5 // This file defines functions that integrate Chrome in Windows shell. These 5 // This file defines functions that integrate Chrome in Windows shell. These
6 // functions can be used by Chrome as well as Chrome installer. All of the 6 // functions can be used by Chrome as well as Chrome installer. All of the
7 // work is done by the local functions defined in anonymous namespace in 7 // work is done by the local functions defined in anonymous namespace in
8 // this class. 8 // this class.
9 9
10 #include "chrome/installer/util/shell_util.h" 10 #include "chrome/installer/util/shell_util.h"
11 11
12 #include <shlobj.h> 12 #include <shlobj.h>
13 #include <windows.h> 13 #include <windows.h>
14 14
15 #include <limits> 15 #include <limits>
16 #include <list> 16 #include <list>
17 #include <string>
17 18
18 #include "base/command_line.h" 19 #include "base/command_line.h"
19 #include "base/file_path.h" 20 #include "base/file_path.h"
20 #include "base/file_util.h" 21 #include "base/file_util.h"
21 #include "base/lazy_instance.h" 22 #include "base/lazy_instance.h"
22 #include "base/logging.h" 23 #include "base/logging.h"
23 #include "base/md5.h" 24 #include "base/md5.h"
24 #include "base/memory/scoped_ptr.h" 25 #include "base/memory/scoped_ptr.h"
25 #include "base/path_service.h" 26 #include "base/path_service.h"
26 #include "base/stl_util.h" 27 #include "base/stl_util.h"
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 }; // class UserSpecificRegistrySuffix 134 }; // class UserSpecificRegistrySuffix
134 135
135 UserSpecificRegistrySuffix::UserSpecificRegistrySuffix() { 136 UserSpecificRegistrySuffix::UserSpecificRegistrySuffix() {
136 string16 user_sid; 137 string16 user_sid;
137 if (!base::win::GetUserSidString(&user_sid)) { 138 if (!base::win::GetUserSidString(&user_sid)) {
138 NOTREACHED(); 139 NOTREACHED();
139 return; 140 return;
140 } 141 }
141 COMPILE_ASSERT(sizeof(base::MD5Digest) == 16, size_of_MD5_not_as_expected_); 142 COMPILE_ASSERT(sizeof(base::MD5Digest) == 16, size_of_MD5_not_as_expected_);
142 base::MD5Digest md5_digest; 143 base::MD5Digest md5_digest;
143 base::MD5Sum(user_sid.c_str(), user_sid.length(), &md5_digest); 144 std::string user_sid_ascii(UTF16ToASCII(user_sid));
145 base::MD5Sum(user_sid_ascii.c_str(), user_sid_ascii.length(), &md5_digest);
144 const string16 base32_md5( 146 const string16 base32_md5(
145 ShellUtil::ByteArrayToBase32(md5_digest.a, arraysize(md5_digest.a))); 147 ShellUtil::ByteArrayToBase32(md5_digest.a, arraysize(md5_digest.a)));
146 // The value returned by the base32 algorithm above must never change and 148 // The value returned by the base32 algorithm above must never change and
147 // must always be 26 characters long (i.e. if someone ever moves this to 149 // must always be 26 characters long (i.e. if someone ever moves this to
148 // base and implements the full base32 algorithm (i.e. with appended '=' 150 // base and implements the full base32 algorithm (i.e. with appended '='
149 // signs in the output), they must provide a flag to allow this method to 151 // signs in the output), they must provide a flag to allow this method to
150 // still request the output with no appended '=' signs). 152 // still request the output with no appended '=' signs).
151 DCHECK_EQ(base32_md5.length(), 26U); 153 DCHECK_EQ(base32_md5.length(), 26U);
152 suffix_.reserve(base32_md5.length() + 1); 154 suffix_.reserve(base32_md5.length() + 1);
153 suffix_.assign(1, L'.'); 155 suffix_.assign(1, L'.');
(...skipping 1516 matching lines...) Expand 10 before | Expand all | Expand 10 after
1670 // are any left...). 1672 // are any left...).
1671 if (free_bits >= 8 && next_byte_index < size) { 1673 if (free_bits >= 8 && next_byte_index < size) {
1672 free_bits -= 8; 1674 free_bits -= 8;
1673 bit_stream += bytes[next_byte_index++] << free_bits; 1675 bit_stream += bytes[next_byte_index++] << free_bits;
1674 } 1676 }
1675 } 1677 }
1676 1678
1677 DCHECK_EQ(ret.length(), encoded_length); 1679 DCHECK_EQ(ret.length(), encoded_length);
1678 return ret; 1680 return ret;
1679 } 1681 }
OLDNEW
« 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