summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-14 22:57:57 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-02-14 22:57:57 +0000
commitd7b43e68b5c791eb689a5bc23671de3aabc59c3c (patch)
treea7583069aa15fbb529864eacbb87ad6c4f0e6fef
parent8792b698c8b1d128cfd5ed184ab3cbd5a0615046 (diff)
downloadchromium_src-d7b43e68b5c791eb689a5bc23671de3aabc59c3c.zip
chromium_src-d7b43e68b5c791eb689a5bc23671de3aabc59c3c.tar.gz
chromium_src-d7b43e68b5c791eb689a5bc23671de3aabc59c3c.tar.bz2
Use case-insensitive comparison when comparing JIDs.
BUG=None TEST=None Review URL: http://codereview.chromium.org/6518012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@74866 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--remoting/host/access_verifier.cc13
-rw-r--r--remoting/host/access_verifier_unittest.cc4
2 files changed, 15 insertions, 2 deletions
diff --git a/remoting/host/access_verifier.cc b/remoting/host/access_verifier.cc
index 6271816..9e37da3 100644
--- a/remoting/host/access_verifier.cc
+++ b/remoting/host/access_verifier.cc
@@ -34,9 +34,18 @@ bool AccessVerifier::VerifyPermissions(
const std::string& client_jid,
const std::string& encoded_access_token) {
CHECK(initialized_);
+
+ // Reject incoming connection if the client's jid is not an ASCII string.
+ if (!IsStringASCII(client_jid)) {
+ LOG(ERROR) << "Rejecting incoming connection from " << client_jid;
+ return false;
+ }
+
// Check that the client has the same bare jid as the host, i.e.
- // client's full jid starts with host's bare jid.
- if (!StartsWithASCII(client_jid, host_jid_prefix_, true)) {
+ // client's full JID starts with host's bare jid. Comparison is case
+ // insensitive.
+ if (!StartsWithASCII(client_jid, host_jid_prefix_, false)) {
+ LOG(ERROR) << "Rejecting incoming connection from " << client_jid;
return false;
}
diff --git a/remoting/host/access_verifier_unittest.cc b/remoting/host/access_verifier_unittest.cc
index 682cf1f..ae0028b 100644
--- a/remoting/host/access_verifier_unittest.cc
+++ b/remoting/host/access_verifier_unittest.cc
@@ -38,12 +38,16 @@ TEST_F(AccessVerifierTest, VerifyPermissions) {
InitConfig();
ASSERT_TRUE(target.Init(config_));
EXPECT_TRUE(target.VerifyPermissions("host@domain.com/123123", ""));
+ EXPECT_TRUE(target.VerifyPermissions("hOsT@domain.com/123123", ""));
EXPECT_FALSE(target.VerifyPermissions("host@domain.com", ""));
EXPECT_FALSE(target.VerifyPermissions("otherhost@domain.com/123123", ""));
EXPECT_FALSE(target.VerifyPermissions("host@otherdomain.com/123123", ""));
EXPECT_FALSE(target.VerifyPermissions("", ""));
EXPECT_FALSE(target.VerifyPermissions("host@domain.co/saf", ""));
EXPECT_FALSE(target.VerifyPermissions("host@domain.com.other/blah", ""));
+
+ // Non ASCII string.
+ EXPECT_FALSE(target.VerifyPermissions("абв@domain.com/saf", ""));
}
} // namespace remoting