Commit e7563c06 authored by Joe Downing's avatar Joe Downing Committed by Commit Bot

Fixing a crash in the It2Me host after disconnect

This crash is occurring when the user clicks 'stop sharing' on the
remote session.  The website will send a disconnect message which cleans
up the It2Me host and friends.  The website will then create a new
instance of the native message host (which it uses to determine if the
host is installed).  Soon after this, the host website receives a
session-terminate message from the client.  It helpfully sends this to
the It2Me host.  Since signaling is not connected for the new host
instance, it tries to run the incoming_message_callback_ (which is
invalid) and crashes.

This CL adds a check around incoming_message_callback_ to ensure it is
valid before calling it (as well as some logging to indicate the
condition occurred).  It's possible that we could address this issue in
the client w/o requiring a host fix but I think it is a good idea to
handle this scenario in case it is too difficult to fix client-side or a
regression sneaks in later.

Bug: 1084670
Change-Id: I3714fc860339b12cfcab688652e5e8a83118a4f5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2210732Reviewed-by: default avatarJamie Walch <jamiewalch@chromium.org>
Commit-Queue: Joe Downing <joedow@chromium.org>
Cr-Commit-Position: refs/heads/master@{#770721}
parent ae487c55
...@@ -363,7 +363,12 @@ void It2MeNativeMessagingHost::ProcessIncomingIq( ...@@ -363,7 +363,12 @@ void It2MeNativeMessagingHost::ProcessIncomingIq(
return; return;
} }
incoming_message_callback_.Run(iq); if (incoming_message_callback_) {
incoming_message_callback_.Run(iq);
} else {
LOG(WARNING) << "Dropping message because signaling is not connected. "
<< "Current It2MeHost state: " << state_;
}
SendMessageToClient(std::move(response)); SendMessageToClient(std::move(response));
} }
......
...@@ -147,7 +147,7 @@ class It2MeNativeMessagingHost : public It2MeHost::Observer, ...@@ -147,7 +147,7 @@ class It2MeNativeMessagingHost : public It2MeHost::Observer,
#endif #endif
// Cached, read-only copies of |it2me_host_| session state. // Cached, read-only copies of |it2me_host_| session state.
It2MeHostState state_; It2MeHostState state_ = It2MeHostState::kDisconnected;
std::string access_code_; std::string access_code_;
base::TimeDelta access_code_lifetime_; base::TimeDelta access_code_lifetime_;
std::string client_username_; std::string client_username_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment