[telepathy-gabble/master] gabble_jingle_content_parse_add: clarify behaviour of libjingle 0.3 mode

Simon McVittie simon.mcvittie at collabora.co.uk
Thu Aug 20 03:18:04 PDT 2009


When google_mode is TRUE and trans_node is NULL (i.e. the remote party
is using libjingle 0.3 or an emulation of it), the transport is implicitly
gtalk-p2p, because libjingle 0.3's protocol has no concept of transports.
To select this transport, we look up the empty string as a
pseudo-namespace in the factory's registry of transport types, which
in practice returns GABBLE_TYPE_JINGLE_TRANSPORT_GOOGLE.

This results in a coverity false positive a little further down,
where we select a transport based on trans_node (assumed to be non-NULL)
 if transport_type is zero. This is in fact safe, but coverity can't tell
that (it can't see that transport_type will be nonzero as a result of the
lookup), and it's not immediately obvious to programmers either.

To make this clearer, add a check that will, in practice, always succeed
(unless we delete the gtalk-p2p code for some strange reason).

Reviewed-by: Will Thompson <will.thompson at collabora.co.uk>
---
 src/jingle-content.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/src/jingle-content.c b/src/jingle-content.c
index 62790a1..ce0b01e 100644
--- a/src/jingle-content.c
+++ b/src/jingle-content.c
@@ -479,6 +479,14 @@ gabble_jingle_content_parse_add (GabbleJingleContent *c,
           g_object_set (c->session, "dialect", JINGLE_DIALECT_GTALK3, NULL);
           transport_type = gabble_jingle_factory_lookup_transport (
               c->conn->jingle_factory, "");
+
+          /* in practice we do support gtalk-p2p, so this can't happen */
+          if (G_UNLIKELY (transport_type == 0))
+            {
+              SET_BAD_REQ ("gtalk-p2p transport unsupported");
+              return;
+            }
+
           priv->transport_ns = g_strdup ("");
         }
     }
-- 
1.5.6.5



More information about the telepathy-commits mailing list