From 3869cb3f33d2694fa94b7a6d45b52c9a7568a2a2 Mon Sep 17 00:00:00 2001 From: defanor Date: Sat, 28 Mar 2020 04:33:26 +0300 Subject: Check "from" on roster push --- README | 11 ++++++----- src/rexmpp.c | 13 ++++++++++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/README b/README index badd92e..fd1723f 100644 --- a/README +++ b/README @@ -54,14 +54,15 @@ A rough roadmap: [ ] Separate states for server-to-client and client-to-server streams? -- Primary IM features (?): +- Primary IM features: -[.] XMPP IM (RFC 6121): loading and managing of the roster and - presence subscriptions. Optional roster management (loading and - updates on roster push, with versioning) is implemented. +[.] XMPP IM (RFC 6121): loading and managing of the roster, possibly + keeping track of contact presences. Optional roster management + (loading and updates on roster push, with versioning) is + implemented. -- Common and reliable IM features (?): +- Common and reliable IM features: [.] XEP-0030: Service Discovery (implemented partially, just to discover server features) diff --git a/src/rexmpp.c b/src/rexmpp.c index fe04481..d2d3dd8 100644 --- a/src/rexmpp.c +++ b/src/rexmpp.c @@ -1204,7 +1204,18 @@ void rexmpp_process_element (rexmpp_t *s) { /* IQ "set" requests. */ if (strcmp(type, "set") == 0) { xmlNodePtr query = xmlFirstElementChild(elem); - if (s->manage_roster && + int from_server = 0; + char *from = xmlGetProp(elem, "from"); + if (from == NULL) { + from_server = 1; + } else { + if (strcmp(from, jid_bare_to_host(s->assigned_jid)) == 0) { + from_server = 1; + } + free(from); + } + if (from_server && + s->manage_roster && rexmpp_xml_match(query, "jabber:iq:roster", "query")) { /* Roster push. */ if (s->roster_ver != NULL) { -- cgit v1.2.3