From f6da386dea748fd1b82be4b337e267a9fa65cae0 Mon Sep 17 00:00:00 2001 From: Florian Schmaus Date: Fri, 14 Dec 2018 17:18:53 +0100 Subject: [PATCH] Ensure that IQ response 'to' address and ID are set correctly Fixes SMACK-845. --- .../java/org/jivesoftware/smack/AbstractXMPPConnection.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java index 6ab848c50..52fe2138e 100644 --- a/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java +++ b/smack-core/src/main/java/org/jivesoftware/smack/AbstractXMPPConnection.java @@ -1097,6 +1097,7 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { if (packet instanceof IQ) { final IQ iq = (IQ) packet; if (iq.isRequestIQ()) { + final IQ iqRequest = iq; final String key = XmppStringUtils.generateKey(iq.getChildElementName(), iq.getChildElementNamespace()); IQRequestHandler iqRequestHandler; final IQ.Type type = iq.getType(); @@ -1162,6 +1163,11 @@ public abstract class AbstractXMPPConnection implements XMPPConnection { // e.g. to avoid presence leaks. return; } + + assert (response.getType() == IQ.Type.result || response.getType() == IQ.Type.error); + + response.setTo(iqRequest.getFrom()); + response.setStanzaId(iqRequest.getStanzaId()); try { sendStanza(response); }