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

This commit is contained in:
Daniel Gultsch 2021-01-03 16:05:17 +01:00
parent 8eb685a7eb
commit 2bec5459c5
2 changed files with 7 additions and 5 deletions

View File

@ -77,7 +77,7 @@ public class FileBackend {
private static final String FILE_PROVIDER = ".files"; private static final String FILE_PROVIDER = ".files";
private static final float IGNORE_PADDING = 0.15f; private static final float IGNORE_PADDING = 0.15f;
private XmppConnectionService mXmppConnectionService; private final XmppConnectionService mXmppConnectionService;
public FileBackend(XmppConnectionService service) { public FileBackend(XmppConnectionService service) {
this.mXmppConnectionService = service; this.mXmppConnectionService = service;

View File

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