diff options
author | defanor <defanor@uberspace.net> | 2020-04-02 03:50:20 +0300 |
---|---|---|
committer | defanor <defanor@uberspace.net> | 2020-04-02 03:50:20 +0300 |
commit | e8089ba3448724a08acb13fd17475f62cd3ef2c0 (patch) | |
tree | 30061f2c67996a14c8fcdeb1944db5b87e1c9334 | |
parent | 62ec4a47bf097c166b2866e8cb38a4fcd8ae41f7 (diff) |
Check JIDs in IQ replies
-rw-r--r-- | src/rexmpp.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/rexmpp.c b/src/rexmpp.c index 050f86b..391364f 100644 --- a/src/rexmpp.c +++ b/src/rexmpp.c @@ -1337,7 +1337,16 @@ void rexmpp_process_element (rexmpp_t *s) { int found = 0; while (req != NULL && found == 0) { char *req_id = xmlGetProp(req->request, "id"); - if (strcmp(id, req_id) == 0) { + char *req_to = xmlGetProp(req->request, "to"); + char *rep_from = xmlGetProp(elem, "from"); + int id_matches = (strcmp(id, req_id) == 0); + int jid_matches = 0; + if (req_to == NULL && rep_from == NULL) { + jid_matches = 1; + } else if (req_to != NULL && rep_from != NULL) { + jid_matches = (strcmp(req_to, rep_from) == 0); + } + if (id_matches && jid_matches) { found = 1; if (req->cb != NULL) { char *iq_type = xmlGetProp(elem, "type"); @@ -1367,6 +1376,12 @@ void rexmpp_process_element (rexmpp_t *s) { xmlFreeNode(req->request); free(req); } + if (req_to != NULL) { + free(req_to); + } + if (rep_from != NULL) { + free(rep_from); + } free(req_id); req = req->next; } |