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

Unified Diff: webrtc/p2p/base/turnport.cc

Issue 2837133003: Don't crash if STUN error message is missing ERROR-CODE attribute. (Closed)
Patch Set: Created 3 years, 8 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 | « webrtc/p2p/base/stunport.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/turnport.cc
diff --git a/webrtc/p2p/base/turnport.cc b/webrtc/p2p/base/turnport.cc
index 90151692215e23d773524600dc0cfb1141576a6e..56dadde9bb1521845bfad4e43dc5e7bce5370c4f 100644
--- a/webrtc/p2p/base/turnport.cc
+++ b/webrtc/p2p/base/turnport.cc
@@ -1165,19 +1165,18 @@ void TurnAllocateRequest::OnResponse(StunMessage* response) {
void TurnAllocateRequest::OnErrorResponse(StunMessage* response) {
// Process error response according to RFC5766, Section 6.4.
- const StunErrorCodeAttribute* error_code = response->GetErrorCode();
+ int error_code = response->GetErrorCodeValue();
LOG_J(LS_INFO, port_) << "Received TURN allocate error response"
<< ", id=" << rtc::hex_encode(id())
- << ", code=" << error_code->code()
- << ", rtt=" << Elapsed();
+ << ", code=" << error_code << ", rtt=" << Elapsed();
- switch (error_code->code()) {
+ switch (error_code) {
case STUN_ERROR_UNAUTHORIZED: // Unauthrorized.
- OnAuthChallenge(response, error_code->code());
+ OnAuthChallenge(response, error_code);
break;
case STUN_ERROR_TRY_ALTERNATE:
- OnTryAlternate(response, error_code->code());
+ OnTryAlternate(response, error_code);
break;
case STUN_ERROR_ALLOCATION_MISMATCH:
// We must handle this error async because trying to delete the socket in
@@ -1186,10 +1185,10 @@ void TurnAllocateRequest::OnErrorResponse(StunMessage* response) {
TurnPort::MSG_ALLOCATE_MISMATCH);
break;
default:
- LOG_J(LS_WARNING, port_) << "Received TURN allocate error response"
- << ", id=" << rtc::hex_encode(id())
- << ", code=" << error_code->code()
- << ", rtt=" << Elapsed();
+ LOG_J(LS_WARNING, port_)
+ << "Received TURN allocate error response"
+ << ", id=" << rtc::hex_encode(id()) << ", code=" << error_code
+ << ", rtt=" << Elapsed();
port_->OnAllocateError();
}
}
@@ -1321,20 +1320,20 @@ void TurnRefreshRequest::OnResponse(StunMessage* response) {
}
void TurnRefreshRequest::OnErrorResponse(StunMessage* response) {
- const StunErrorCodeAttribute* error_code = response->GetErrorCode();
+ int error_code = response->GetErrorCodeValue();
- if (error_code->code() == STUN_ERROR_STALE_NONCE) {
+ if (error_code == STUN_ERROR_STALE_NONCE) {
if (port_->UpdateNonce(response)) {
// Send RefreshRequest immediately.
port_->SendRequest(new TurnRefreshRequest(port_), 0);
}
} else {
- LOG_J(LS_WARNING, port_) << "Received TURN refresh error response"
- << ", id=" << rtc::hex_encode(id())
- << ", code=" << error_code->code()
- << ", rtt=" << Elapsed();
+ LOG_J(LS_WARNING, port_)
+ << "Received TURN refresh error response"
+ << ", id=" << rtc::hex_encode(id()) << ", code=" << error_code
+ << ", rtt=" << Elapsed();
port_->OnRefreshError();
- port_->SignalTurnRefreshResult(port_, error_code->code());
+ port_->SignalTurnRefreshResult(port_, error_code);
}
}
@@ -1380,13 +1379,12 @@ void TurnCreatePermissionRequest::OnResponse(StunMessage* response) {
}
void TurnCreatePermissionRequest::OnErrorResponse(StunMessage* response) {
- const StunErrorCodeAttribute* error_code = response->GetErrorCode();
+ int error_code = response->GetErrorCodeValue();
LOG_J(LS_WARNING, port_) << "Received TURN create permission error response"
<< ", id=" << rtc::hex_encode(id())
- << ", code=" << error_code->code()
- << ", rtt=" << Elapsed();
+ << ", code=" << error_code << ", rtt=" << Elapsed();
if (entry_) {
- entry_->OnCreatePermissionError(response, error_code->code());
+ entry_->OnCreatePermissionError(response, error_code);
}
}
@@ -1450,13 +1448,12 @@ void TurnChannelBindRequest::OnResponse(StunMessage* response) {
}
void TurnChannelBindRequest::OnErrorResponse(StunMessage* response) {
- const StunErrorCodeAttribute* error_code = response->GetErrorCode();
+ int error_code = response->GetErrorCodeValue();
LOG_J(LS_WARNING, port_) << "Received TURN channel bind error response"
<< ", id=" << rtc::hex_encode(id())
- << ", code=" << error_code->code()
- << ", rtt=" << Elapsed();
+ << ", code=" << error_code << ", rtt=" << Elapsed();
if (entry_) {
- entry_->OnChannelBindError(response, error_code->code());
+ entry_->OnChannelBindError(response, error_code);
}
}
« no previous file with comments | « webrtc/p2p/base/stunport.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698