OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // windows.h must be first otherwise Win8 SDK breaks. | 5 // windows.h must be first otherwise Win8 SDK breaks. |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <LM.h> | 7 #include <LM.h> |
8 #include <wincred.h> | 8 #include <wincred.h> |
9 | 9 |
10 // SECURITY_WIN32 must be defined in order to get | 10 // SECURITY_WIN32 must be defined in order to get |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 WCHAR username[CREDUI_MAX_USERNAME_LENGTH+1] = {}; | 122 WCHAR username[CREDUI_MAX_USERNAME_LENGTH+1] = {}; |
123 OsPasswordStatus retVal = PASSWORD_STATUS_UNKNOWN; | 123 OsPasswordStatus retVal = PASSWORD_STATUS_UNKNOWN; |
124 | 124 |
125 if (GetUserNameEx(NameUserPrincipal, username, &username_length)) { | 125 if (GetUserNameEx(NameUserPrincipal, username, &username_length)) { |
126 // If we are on a domain, it is almost certain that the password is not | 126 // If we are on a domain, it is almost certain that the password is not |
127 // blank, but we do not actively check any further than this to avoid any | 127 // blank, but we do not actively check any further than this to avoid any |
128 // failed login attempts hitting the domain controller. | 128 // failed login attempts hitting the domain controller. |
129 retVal = PASSWORD_STATUS_WIN_DOMAIN; | 129 retVal = PASSWORD_STATUS_WIN_DOMAIN; |
130 } else { | 130 } else { |
131 username_length = CREDUI_MAX_USERNAME_LENGTH; | 131 username_length = CREDUI_MAX_USERNAME_LENGTH; |
132 if (GetUserName(username, &username_length)) { | 132 // CheckBlankPassword() isn't safe to call on before Windows 7. |
| 133 // http://crbug.com/345916 |
| 134 if (base::win::GetVersion() >= base::win::VERSION_WIN7 && |
| 135 GetUserName(username, &username_length)) { |
133 retVal = CheckBlankPassword(username) ? PASSWORD_STATUS_BLANK : | 136 retVal = CheckBlankPassword(username) ? PASSWORD_STATUS_BLANK : |
134 PASSWORD_STATUS_NONBLANK; | 137 PASSWORD_STATUS_NONBLANK; |
135 } | 138 } |
136 } | 139 } |
137 | 140 |
138 return retVal; | 141 return retVal; |
139 } | 142 } |
140 | 143 |
141 bool AuthenticateUser(gfx::NativeWindow window) { | 144 bool AuthenticateUser(gfx::NativeWindow window) { |
142 bool retval = false; | 145 bool retval = false; |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
235 } | 238 } |
236 } | 239 } |
237 SecureZeroMemory(password, sizeof(password)); | 240 SecureZeroMemory(password, sizeof(password)); |
238 } | 241 } |
239 } while (credErr == NO_ERROR && | 242 } while (credErr == NO_ERROR && |
240 (retval == false && tries < kMaxPasswordRetries)); | 243 (retval == false && tries < kMaxPasswordRetries)); |
241 return retval; | 244 return retval; |
242 } | 245 } |
243 | 246 |
244 } // namespace password_manager_util | 247 } // namespace password_manager_util |
OLD | NEW |