properly null check ufrag and pwd before whitespace checking. fixes #3956

(cherry picked from commit 2bec5459c5)
This commit is contained in:
Daniel Gultsch 2021-01-03 16:05:17 +01:00 committed by Christian Schneppe
parent 100d101151
commit 1f9b0538ab
2 changed files with 7 additions and 5 deletions

View file

@ -85,7 +85,7 @@ public class FileBackend {
private static final String FILE_PROVIDER = ".files";
private static final String APP_DIRECTORY = "blabber.im";
private XmppConnectionService mXmppConnectionService;
private final XmppConnectionService mXmppConnectionService;
public FileBackend(XmppConnectionService service) {
this.mXmppConnectionService = service;

View file

@ -143,14 +143,16 @@ public class SessionDescription {
final ArrayListMultimap<String, String> mediaAttributes = ArrayListMultimap.create();
final String ufrag = transport.getAttribute("ufrag");
final String pwd = transport.getAttribute("pwd");
if (!Strings.isNullOrEmpty(ufrag)) {
mediaAttributes.put("ice-ufrag", ufrag);
if (Strings.isNullOrEmpty(ufrag)) {
throw new IllegalArgumentException("Transport element is missing required ufrag attribute");
}
checkNoWhitespace(ufrag, "ufrag value must not contain any whitespaces");
if (!Strings.isNullOrEmpty(pwd)) {
mediaAttributes.put("ice-pwd", pwd);
mediaAttributes.put("ice-ufrag", ufrag);
if (Strings.isNullOrEmpty(pwd)) {
throw new IllegalArgumentException("Transport element is missing required pwd attribute");
}
checkNoWhitespace(pwd, "pwd value must not contain any whitespaces");
mediaAttributes.put("ice-pwd", pwd);
mediaAttributes.put("ice-options", HARDCODED_ICE_OPTIONS);
final IceUdpTransportInfo.Fingerprint fingerprint = transport.getFingerprint();
if (fingerprint != null) {