0

Handle malformed email addresses in remoting_me2me_host

This is a speculative fix for a crash we are seeing in
ApplyHostDomainListPolicy() where I think either the provisioning
or heartbeat RPC is providing an invalid email address for the
user account. Note that if this is occurring, there will likely
be problems later on (for example a malformed email won't match
the sender_id in signaling messages) but those failures will be
logged rather than crashing the host.

I'm also proactively addressing the same potential problem
when session authz policies are applied.

Bug: 398725077
Change-Id: I8a2c5093ffa5059d341b6546885fb84e8b48046b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6310015
Reviewed-by: Gary Kacmarcik <garykac@chromium.org>
Auto-Submit: Joe Downing <joedow@chromium.org>
Commit-Queue: Gary Kacmarcik <garykac@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1425779}
This commit is contained in:
Joe Downing
2025-02-27 08:51:55 -08:00
committed by Chromium LUCI CQ
parent 877c1b9818
commit 83e1c344f2

@ -1466,7 +1466,12 @@ void HostProcess::ApplyHostDomainListPolicy() {
std::set<std::string> allowed_emails;
for (const std::string& owner_email : host_owner_emails_) {
auto [_, domain] = *base::SplitStringOnce(owner_email, '@');
auto email_parts = base::SplitStringOnce(owner_email, '@');
if (!email_parts.has_value()) {
LOG(WARNING) << owner_email << " is not a valid email address";
continue;
}
auto domain = email_parts->second;
bool allowed_by_policy = IsInAllowlist(domain, host_domain_list_);
if (allowed_by_policy) {
allowed_emails.emplace(owner_email);
@ -1668,7 +1673,12 @@ std::optional<ErrorCode> HostProcess::OnSessionPoliciesReceived(
LOG(INFO) << "Current local username is '" << username << "'";
std::set<std::string> allowed_emails;
for (const std::string& owner_email : host_owner_emails_) {
auto [owner_username, _] = *base::SplitStringOnce(owner_email, '@');
auto email_parts = base::SplitStringOnce(owner_email, '@');
if (!email_parts.has_value()) {
LOG(WARNING) << owner_email << " is not a valid email address";
continue;
}
auto owner_username = email_parts->first;
if (base::EqualsCaseInsensitiveASCII(username, owner_username)) {
LOG(INFO) << owner_email << " matches the local username";
allowed_emails.emplace(owner_email);