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

Unified Diff: components/password_manager/core/browser/login_database.cc

Issue 842163002: LoginDatabase::AddLogin should handle correctly incorrect input. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DoesMatchConstraints Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | components/password_manager/core/browser/login_database_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/password_manager/core/browser/login_database.cc
diff --git a/components/password_manager/core/browser/login_database.cc b/components/password_manager/core/browser/login_database.cc
index a9d329f3d63f36b1bbc97022500f1b0882adf7c1..4fd2a42f01e3e63beb22eaad244da7a4c6dd60e2 100644
--- a/components/password_manager/core/browser/login_database.cc
+++ b/components/password_manager/core/browser/login_database.cc
@@ -118,6 +118,18 @@ void AddCallback(int err, sql::Statement* /*stmt*/) {
DLOG(WARNING) << "LoginDatabase::AddLogin updated an existing form";
}
+bool DoesMatchConstraints(const PasswordForm& form) {
+ if (form.origin.is_empty()) {
+ DLOG(ERROR) << "Constraint violation: form.origin is empty";
+ return false;
+ }
+ if (form.signon_realm.empty()) {
+ DLOG(ERROR) << "Constraint violation: form.signon_realm is empty";
+ return false;
+ }
+ return true;
+}
+
// UMA_* macros assume that the name never changes. This is a helper function
// where this assumption doesn't hold.
void LogDynamicUMAStat(const std::string& name,
@@ -430,6 +442,8 @@ void LoginDatabase::ReportMetrics(const std::string& sync_username,
PasswordStoreChangeList LoginDatabase::AddLogin(const PasswordForm& form) {
PasswordStoreChangeList list;
+ if (!DoesMatchConstraints(form))
+ return list;
std::string encrypted_password;
if (EncryptedString(form.password_value, &encrypted_password) !=
ENCRYPTION_RESULT_SUCCESS)
« no previous file with comments | « no previous file | components/password_manager/core/browser/login_database_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698