mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
omemo: Check stanza names when iterating nodes
Some clients (eg. PSI) are sending the stanzas delimited by whitespace text nodes, which will fail while looping through the <prekeys/> children and also print weird errors when iterating through the <list/> of devices. When debugging this, I was looking at the XML of Gajim and PSI and first was somehow confused why Profanity printed "OMEMO: received device without ID" while the XML looked identical (minus the actual IDs and the JIDs of course). However, Gajim was sending the XML without whitespace nodes in between and PSI did not, so for example the following (with the relevant whitespace nodes marked with X): <message type="headline" to="..." from="..."> <event xmlns="http://jabber.org/protocol/pubsub#event"> <items type="headline" node="eu.siacs.conversations.axolotl.devicelist"> <item id="..."> <list xmlns="eu.siacs.conversations.axolotl"> X <device id="..."/> X <device id="..."/> X </list> </item> </items> </event> <delay xmlns="urn:xmpp:delay" stamp="..." from="..."/> </message> ... would result in three times the "OMEMO: received device without ID" error, because we actually have three XML text nodes here that obviously don't have an "id" attribute. Now since the <list/> children above aren't really a problem and only annoying, text nodes in the <prekeys/> stanza actually cause omemo_start_device_session_handle_bundle to return failure. I've fixed this by explicitly matching the stanza names we are interested in, skipping everything else. Signed-off-by: aszlig <aszlig@nix.build> Reported-by: @devhell
This commit is contained in:
parent
900426025e
commit
b1e960cfae
@ -164,6 +164,10 @@ omemo_start_device_session_handle_bundle(xmpp_stanza_t *const stanza, void *cons
|
|||||||
|
|
||||||
xmpp_stanza_t *prekey;
|
xmpp_stanza_t *prekey;
|
||||||
for (prekey = xmpp_stanza_get_children(prekeys); prekey != NULL; prekey = xmpp_stanza_get_next(prekey)) {
|
for (prekey = xmpp_stanza_get_children(prekeys); prekey != NULL; prekey = xmpp_stanza_get_next(prekey)) {
|
||||||
|
if (g_strcmp0(xmpp_stanza_get_name(prekey), "preKeyPublic") != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
omemo_key_t *key = malloc(sizeof(omemo_key_t));
|
omemo_key_t *key = malloc(sizeof(omemo_key_t));
|
||||||
key->data = NULL;
|
key->data = NULL;
|
||||||
|
|
||||||
@ -378,6 +382,10 @@ _omemo_receive_devicelist(xmpp_stanza_t *const stanza, void *const userdata)
|
|||||||
|
|
||||||
xmpp_stanza_t *device;
|
xmpp_stanza_t *device;
|
||||||
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
for (device = xmpp_stanza_get_children(list); device != NULL; device = xmpp_stanza_get_next(device)) {
|
||||||
|
if (g_strcmp0(xmpp_stanza_get_name(device), "device") != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const char *id = xmpp_stanza_get_id(device);
|
const char *id = xmpp_stanza_get_id(device);
|
||||||
if (id != NULL) {
|
if (id != NULL) {
|
||||||
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
device_list = g_list_append(device_list, GINT_TO_POINTER(strtoul(id, NULL, 10)));
|
||||||
|
Loading…
Reference in New Issue
Block a user