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

Unified Diff: chrome/browser/extensions/api/cast_channel/cast_socket.cc

Issue 408633002: Fix error handling for message parse errors that occur during connection setup. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Allow read event loop to close socket on error. Created 6 years, 5 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/api/cast_channel/cast_socket.cc
diff --git a/chrome/browser/extensions/api/cast_channel/cast_socket.cc b/chrome/browser/extensions/api/cast_channel/cast_socket.cc
index 6130d92e18755dc825880177b785f7536baf5afc..15ed3ce0ce9b12ad07ec3f3094e52e317f4ec643 100644
--- a/chrome/browser/extensions/api/cast_channel/cast_socket.cc
+++ b/chrome/browser/extensions/api/cast_channel/cast_socket.cc
@@ -158,7 +158,7 @@ bool CastSocket::ExtractPeerCert(std::string* cert) {
}
bool CastSocket::VerifyChallengeReply() {
- return AuthenticateChallengeReply(*challenge_reply_.get(), peer_cert_);
+ return AuthenticateChallengeReply(*challenge_reply_, peer_cert_);
mark a. foltz 2014/07/21 17:38:52 Thank you for fixing this, in my email reply I for
Kevin M 2014/07/21 20:48:58 Acknowledged.
}
void CastSocket::Connect(const net::CompletionCallback& callback) {
@@ -591,6 +591,7 @@ int CastSocket::DoReadComplete(int result) {
if (!ProcessHeader()) {
error_state_ = cast_channel::CHANNEL_ERROR_INVALID_MESSAGE;
read_state_ = READ_STATE_ERROR;
+ return net::ERR_FAILED;
Wez 2014/07/22 22:33:09 IIUC this change will mean we get read error notif
Kevin M 2014/07/23 18:57:33 This was removed.
}
} else if (current_read_buffer_.get() == body_read_buffer_.get() &&
static_cast<uint32>(current_read_buffer_->offset()) ==
@@ -601,6 +602,7 @@ int CastSocket::DoReadComplete(int result) {
} else {
error_state_ = cast_channel::CHANNEL_ERROR_INVALID_MESSAGE;
read_state_ = READ_STATE_ERROR;
+ return net::ERR_FAILED;
}
}
@@ -609,7 +611,7 @@ int CastSocket::DoReadComplete(int result) {
int CastSocket::DoReadCallback() {
read_state_ = READ_STATE_READ;
- const CastMessage& message = *(current_message_.get());
+ const CastMessage& message = *current_message_;
if (IsAuthMessage(message)) {
// An auth message is received, check that connect flow is running.
if (ready_state_ == READY_STATE_CONNECTING) {
@@ -630,13 +632,14 @@ int CastSocket::DoReadCallback() {
}
int CastSocket::DoReadError(int result) {
+ VLOG_WITH_CONNECTION(1) << "DoReadError: " << result;
DCHECK_LE(result, 0);
+ read_state_ = READ_STATE_NONE;
// If inside connection flow, then get back to connect loop.
mark a. foltz 2014/07/21 17:38:52 I don't fully understand this piece of logic. A re
Kevin M 2014/07/21 20:48:58 Changed the flow to call the completion callback d
mark a. foltz 2014/07/21 21:23:00 I'm not 100% comfortable changing the control flow
Kevin M 2014/07/21 23:50:31 Done. OK, back to the previous method.
if (ready_state_ == READY_STATE_CONNECTING) {
PostTaskToStartConnectLoop(result);
- // does not try to report error also.
Wez 2014/07/22 22:33:09 This comment implies that if we return something o
- return net::OK;
}
+ // Allow the read loop error handler to close the connection.
return net::ERR_FAILED;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698