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

Unified Diff: chromeos/dbus/fake_auth_policy_client.cc

Issue 2653913002: Check username validity in the FakeAuthPolicyClient (Closed)
Patch Set: Add unittests Created 3 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
Index: chromeos/dbus/fake_auth_policy_client.cc
diff --git a/chromeos/dbus/fake_auth_policy_client.cc b/chromeos/dbus/fake_auth_policy_client.cc
index f37f1ea53bc88d6aa576485db9d67fb310e6978b..e97aca0972915221c63098cec4c22944e12b9d98 100644
--- a/chromeos/dbus/fake_auth_policy_client.cc
+++ b/chromeos/dbus/fake_auth_policy_client.cc
@@ -10,6 +10,7 @@
#include "base/location.h"
#include "base/md5.h"
#include "base/path_service.h"
+#include "base/strings/string_split.h"
#include "base/task_scheduler/post_task.h"
#include "chrome/browser/chromeos/policy/proto/chrome_device_policy.pb.h"
#include "chromeos/chromeos_paths.h"
@@ -65,6 +66,13 @@ void FakeAuthPolicyClient::JoinAdDomain(const std::string& machine_name,
const std::string& user_principal_name,
int password_fd,
const JoinCallback& callback) {
+ std::vector<std::string> parts = base::SplitString(
+ user_principal_name, "@", base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+ if (parts.size() != 2 || parts[0].empty() || parts[1].empty()) {
+ callback.Run(authpolicy::ERROR_PARSE_UPN_FAILED);
+ return;
+ }
+
callback.Run(authpolicy::ERROR_NONE);
}

Powered by Google App Engine
This is Rietveld 408576698