From 2bec5459c5a653aba80e6150309a8ca2fa6e8b52 Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 3 Jan 2021 16:05:17 +0100 Subject: [PATCH] properly null check ufrag and pwd before whitespace checking. fixes #3956 --- .../siacs/conversations/persistance/FileBackend.java | 2 +- .../conversations/xmpp/jingle/SessionDescription.java | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java index 977c9fc27..a072e9d9a 100644 --- a/src/main/java/eu/siacs/conversations/persistance/FileBackend.java +++ b/src/main/java/eu/siacs/conversations/persistance/FileBackend.java @@ -77,7 +77,7 @@ public class FileBackend { private static final String FILE_PROVIDER = ".files"; private static final float IGNORE_PADDING = 0.15f; - private XmppConnectionService mXmppConnectionService; + private final XmppConnectionService mXmppConnectionService; public FileBackend(XmppConnectionService service) { this.mXmppConnectionService = service; diff --git a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java index af7213220..52762407f 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java +++ b/src/main/java/eu/siacs/conversations/xmpp/jingle/SessionDescription.java @@ -143,14 +143,16 @@ public class SessionDescription { final ArrayListMultimap 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) {