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

Unified Diff: webrtc/api/peerconnection.cc

Issue 2556783002: Fix out of bound reads in ParseIceServerUrl() for various input. (Closed)
Patch Set: ParseIceServerUrl(): Clarify invalid transport parameter key error message. Created 4 years 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 | webrtc/api/peerconnection_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/peerconnection.cc
diff --git a/webrtc/api/peerconnection.cc b/webrtc/api/peerconnection.cc
index 46bdec594a9c90fcd1630db748921237807902d2..7731c0f4f3e660c4b4c974a526d117dd3ffdf7da 100644
--- a/webrtc/api/peerconnection.cc
+++ b/webrtc/api/peerconnection.cc
@@ -231,21 +231,24 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
std::vector<std::string> tokens;
cricket::ProtocolType turn_transport_type = cricket::PROTO_UDP;
RTC_DCHECK(!url.empty());
- rtc::tokenize(url, '?', &tokens);
+ rtc::tokenize_with_empty_tokens(url, '?', &tokens);
std::string uri_without_transport = tokens[0];
// Let's look into transport= param, if it exists.
if (tokens.size() == kTurnTransportTokensNum) { // ?transport= is present.
std::string uri_transport_param = tokens[1];
- rtc::tokenize(uri_transport_param, '=', &tokens);
- if (tokens[0] == kTransport) {
- // As per above grammar transport param will be consist of lower case
- // letters.
- if (!cricket::StringToProto(tokens[1].c_str(), &turn_transport_type) ||
- (turn_transport_type != cricket::PROTO_UDP &&
- turn_transport_type != cricket::PROTO_TCP)) {
- LOG(LS_WARNING) << "Transport param should always be udp or tcp.";
- return false;
- }
+ rtc::tokenize_with_empty_tokens(uri_transport_param, '=', &tokens);
+ if (tokens[0] != kTransport) {
+ LOG(LS_WARNING) << "Invalid transport parameter key.";
+ return false;
+ }
+ // As per above grammar transport param will be consist of lower case
hta-webrtc 2016/12/09 12:02:09 Drive-by comment: While you're here, can you fix t
hnsl1 2016/12/12 09:28:20 I have a branch where I refactored the whole parse
+ // letters.
+ if (tokens.size() < 2 ||
+ !cricket::StringToProto(tokens[1].c_str(), &turn_transport_type) ||
+ (turn_transport_type != cricket::PROTO_UDP &&
+ turn_transport_type != cricket::PROTO_TCP)) {
+ LOG(LS_WARNING) << "Transport param should always be udp or tcp.";
+ return false;
}
}
« no previous file with comments | « no previous file | webrtc/api/peerconnection_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698