be more strict with ice candidate parsing
This commit is contained in:
parent
0a18ab35c0
commit
fa3ef07580
|
@ -234,7 +234,13 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
for (final Map.Entry<String, RtpContentMap.DescriptionTransport> content : contentMap.contents.entrySet()) {
|
||||
final String ufrag = content.getValue().transport.getAttribute("ufrag");
|
||||
for (final IceUdpTransportInfo.Candidate candidate : content.getValue().transport.getCandidates()) {
|
||||
final String sdp = candidate.toSdpAttribute(ufrag);
|
||||
final String sdp;
|
||||
try {
|
||||
sdp = candidate.toSdpAttribute(ufrag);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.d(Config.LOGTAG,id.account.getJid().asBareJid()+": ignoring invalid ICE candidate "+e.getMessage());
|
||||
continue;
|
||||
}
|
||||
final String sdpMid = content.getKey();
|
||||
final int mLineIndex = identificationTags.indexOf(sdpMid);
|
||||
final IceCandidate iceCandidate = new IceCandidate(sdpMid, mLineIndex, sdp);
|
||||
|
@ -418,8 +424,8 @@ public class JingleRtpConnection extends AbstractJingleConnection implements Web
|
|||
private void addIceCandidatesFromBlackLog() {
|
||||
while (!this.pendingIceCandidates.isEmpty()) {
|
||||
final IceCandidate iceCandidate = this.pendingIceCandidates.poll();
|
||||
this.webRTCWrapper.addIceCandidate(iceCandidate);
|
||||
Log.d(Config.LOGTAG, id.account.getJid().asBareJid() + ": added ICE candidate from back log " + iceCandidate);
|
||||
this.webRTCWrapper.addIceCandidate(iceCandidate);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.util.Log;
|
|||
import com.google.common.base.Function;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.common.base.Strings;
|
||||
import com.google.common.collect.ArrayListMultimap;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
|
@ -188,11 +189,17 @@ public class IceUdpTransportInfo extends GenericTransportInfo {
|
|||
|
||||
public String toSdpAttribute(final String ufrag) {
|
||||
final String foundation = this.getAttribute("foundation");
|
||||
checkNotNullNoWhitespace(foundation, "foundation");
|
||||
final String component = this.getAttribute("component");
|
||||
checkNotNullNoWhitespace(component, "component");
|
||||
final String transport = this.getAttribute("protocol");
|
||||
checkNotNullNoWhitespace(transport, "protocol");
|
||||
final String priority = this.getAttribute("priority");
|
||||
checkNotNullNoWhitespace(priority, "priority");
|
||||
final String connectionAddress = this.getAttribute("ip");
|
||||
checkNotNullNoWhitespace(connectionAddress, "ip");
|
||||
final String port = this.getAttribute("port");
|
||||
checkNotNullNoWhitespace(port, "port");
|
||||
final Map<String, String> additionalParameter = new LinkedHashMap<>();
|
||||
final String relAddr = this.getAttribute("rel-addr");
|
||||
final String type = this.getAttribute("type");
|
||||
|
@ -228,6 +235,13 @@ public class IceUdpTransportInfo extends GenericTransportInfo {
|
|||
}
|
||||
}
|
||||
|
||||
private static void checkNotNullNoWhitespace(final String value, final String name) {
|
||||
if (Strings.isNullOrEmpty(value)) {
|
||||
throw new IllegalArgumentException(String.format("Parameter %s is missing or empty", name));
|
||||
}
|
||||
SessionDescription.checkNoWhitespace(value, String.format("Parameter %s contains white spaces", name));
|
||||
}
|
||||
|
||||
|
||||
public static class Fingerprint extends Element {
|
||||
|
||||
|
|
Loading…
Reference in New Issue