From 2d58b1adaca833f0cbcec897b765a9aa266decc7 Mon Sep 17 00:00:00 2001 From: Will Thompson Date: Fri, 28 Oct 2011 18:34:25 +0100 Subject: [PATCH] roster: ignore multiple replies to roster query. The XMPP server running on vk.com is buggy, and replies to our roster query twice. Gabble just blindly assumed that any with a roster in it was the singular reply to our singular query. This is a pretty reasonable assumption but this buggy server violates it, and Gabble calls tp_base_contact_list_set_list_received() more than once, which triggers a critical in that function. A more invasive fix would use wocky_porter_send_iq_async() rather than scraping all the roster IQs out of everything using the LM API, but I wanted to quickly fix a bug on a Friday afternoon. Fixes: --- src/roster.c | 10 ++++++++++ tests/twisted/roster/test-roster.py | 5 +++++ 2 files changed, 15 insertions(+), 0 deletions(-) diff --git a/src/roster.c b/src/roster.c index 6612f4a..5656662 100644 --- a/src/roster.c +++ b/src/roster.c @@ -1359,6 +1359,16 @@ got_roster_iq (GabbleRoster *roster, return FALSE; } + if (sub_type == WOCKY_STANZA_SUB_TYPE_RESULT && priv->received) + { + /* : some super-buggy + * XMPP server running on vk.com sends its reply to our roster query twice. + */ + DEBUG ("The server sent replied to our roster query more than once! " + "Ignoring this reply"); + return FALSE; + } + process_roster (roster, query_node); if (sub_type == WOCKY_STANZA_SUB_TYPE_RESULT) diff --git a/tests/twisted/roster/test-roster.py b/tests/twisted/roster/test-roster.py index bd89256..04fee09 100644 --- a/tests/twisted/roster/test-roster.py +++ b/tests/twisted/roster/test-roster.py @@ -32,6 +32,11 @@ def test(q, bus, conn, stream): stream.send(event.stanza) + # Regression test for : + # some super-buggy XMPP server running on vk.com sends its reply to our + # roster query twice. This used to crash Gabble. + stream.send(event.stanza) + # slight implementation detail: TpBaseContactList emits ContactsChanged # before it announces its channels s = q.expect('dbus-signal', signal='ContactsChanged', -- 1.7.7