AnsweredAssumed Answered

Smack IQ not correctly implemented with null to field

Question asked by Harshit Bangar on Oct 24, 2015
Latest reply on Oct 29, 2015 by Flow

Hi Flow,

Not sure if this is an issue but smack's iq with no to field or bare jid it doesn't expect a from filter . Ejabberd when given an iq with no to returns a response with barejid: jabberd:iq:roster. 

Smack's fromfilter - https://github.com/igniterealtime/Smack/blob/b18c6dac62bf6d1da8c0f8ab159d426b257 e4754/smack-core/src/main/java/org/jivesoftware/smack/filter/FromMatchesFilter.j ava- The address to filter for. If null is given, the stanza(/packet) must not have a from address.

RFC6120 - https://tools.ietf.org/html/rfc6120#section-8.1.1
When the server generates a stanza from the server for delivery to the client on behalf of the account of the connected client (e.g., in the context of data storage services provided by the
server on behalf of the client), the stanza MUST either (a) not include a 'from' attribute or (b) include a 'from' attribute whose value is the account's bare JID (localpart@domainpart).

 

Packet

<iq id='5t07M-8' type='get'><query xmlns='jabber:iq:roster'></query></iq>

 

<iq from='nishant@ejabberd.sandwitch.in' to='nishant@ejabberd.sandwitch.in/smack' id='5t07M-8' type='result'><query xmlns='jabber:iq:roster'><item ask='subscribe' subscription='none' jid='a@ejabberd.sandwitch.in'/><item subscription='both' jid='deval@ejabberd.sandwitch.in'/><item subscription='both' name='f7ed67f4-8f97-4df5-82b2-09936d71fd8a' jid='harshit@ejabberd.sandwitch.in'/><item subscription='both' jid='pankaj@ejabberd.sandwitch.in'/></query></iq><r xmlns='urn:xmpp:sm:3'/>

 

In IQReplyFilter

    fromFilter = new OrFilter();
    fromFilter.addFilter(FromMatchesFilter.createFull(to));
    if (to == null) {
        fromFilter.addFilter(FromMatchesFilter.createBare(local));
        fromFilter.addFilter(FromMatchesFilter.createFull(server));
    }
    else if (to.equals(local.asBareJid())) {
        fromFilter.addFilter(FromMatchesFilter.createFull(null));
    }

 

to is null and therefore fromfilter first condition is null. In abstrctjid it's giving null pointer since from field is present in iq result. It looks wrong to me.

Outcomes