From 962add97f9fe0df4ac6c9039e3cf2a2d2c5eb98c Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Fri, 27 Oct 2017 18:26:06 +0200 Subject: [PATCH] XmppConnection: throw bind failure when server tries to reassign domain --- .../java/eu/siacs/conversations/xmpp/XmppConnection.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java index 59e7aa6e8..8ea03d75a 100644 --- a/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java +++ b/src/main/java/eu/siacs/conversations/xmpp/XmppConnection.java @@ -1051,7 +1051,12 @@ public class XmppConnection implements Runnable { final Element jid = bind.findChild("jid"); if (jid != null && jid.getContent() != null) { try { - if (account.setJid(Jid.fromString(jid.getContent()))) { + Jid assignedJid = Jid.fromString(jid.getContent()); + if (!account.getJid().getDomainpart().equals(assignedJid.getDomainpart())) { + Log.d(Config.LOGTAG,account.getJid().toBareJid()+": server tried to re-assign domain to "+assignedJid.getDomainpart()); + throw new StateChangingError(Account.State.BIND_FAILURE); + } + if (account.setJid(assignedJid)) { Log.d(Config.LOGTAG, account.getJid().toBareJid() + ": bare jid changed during bind. updating database"); mXmppConnectionService.databaseBackend.updateAccount(account); }