Don't try to parse empty Ice urls.
https://crrev.com/7c4e7458b5ce99c13a75d5be7d718ef94e2f8f9f added support to pass a list of urls for IceServer configurations. This CL fixes a potential crash when empty urls are passed. BUG=2096 R=tommi@webrtc.org Review URL: https://webrtc-codereview.appspot.com/51969004 Cr-Commit-Position: refs/heads/master@{#9334}
This commit is contained in:
parent
a8202aadd5
commit
d935f912b1
@ -186,6 +186,7 @@ bool ParseIceServerUrl(const PeerConnectionInterface::IceServer& server,
|
||||
// turn-port = *DIGIT
|
||||
std::vector<std::string> tokens;
|
||||
std::string turn_transport_type = kUdpTransportType;
|
||||
ASSERT(!url.empty());
|
||||
rtc::tokenize(url, '?', &tokens);
|
||||
std::string uri_without_transport = tokens[0];
|
||||
// Let's look into transport= param, if it exists.
|
||||
@ -286,6 +287,10 @@ bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
|
||||
for (const webrtc::PeerConnectionInterface::IceServer& server : servers) {
|
||||
if (!server.urls.empty()) {
|
||||
for (const std::string& url : server.urls) {
|
||||
if (url.empty()) {
|
||||
LOG(WARNING) << "Empty uri.";
|
||||
continue;
|
||||
}
|
||||
if (!ParseIceServerUrl(server, url, stun_config, turn_config)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -203,6 +203,7 @@ TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServers) {
|
||||
TEST_F(PeerConnectionFactoryTest, CreatePCUsingIceServersUrls) {
|
||||
PeerConnectionInterface::RTCConfiguration config;
|
||||
webrtc::PeerConnectionInterface::IceServer ice_server;
|
||||
ice_server.urls.push_back(""); // Empty URLs should be ignored.
|
||||
ice_server.urls.push_back(kStunIceServer);
|
||||
ice_server.urls.push_back(kTurnIceServer);
|
||||
ice_server.urls.push_back(kTurnIceServerWithTransport);
|
||||
|
Loading…
Reference in New Issue
Block a user