[Bug 47429] Support SalutContact and SautContact-manager with Bonjour backend

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Mar 22 15:28:49 CET 2012


https://bugs.freedesktop.org/show_bug.cgi?id=47429

--- Comment #4 from Olli Salli <olli.salli at collabora.co.uk> 2012-03-22 14:28:49 UTC ---
+static void DNSSD_API
+_bonjour_getaddr_cb (DNSServiceRef service_ref,
+                     DNSServiceFlags flags,
+                     uint32_t interfaceIndex,
+                     DNSServiceErrorType error_type,
+                     const char *host_name,
+                     const struct sockaddr *address,
+                     uint32_t ttl,
+                     void *context)
+{

...

+
+  ctx->address = address;
+
+  DEBUG ("Announce Contact Found");
+  salut_contact_found (contact);
+  salut_contact_thaw (contact);
+}
+

Assuming Bonjour doesn't have a bottomless pit of memory it uses to give you
forever existing sockaddrs via const pointers, your ctx->address pointer will
point to some totally random memory from this point on. Which is to say, always
when it will be used.

To fix this, you'll need to actually store the address. Not just a pointer to
where the address was stored when Bonjour gave it to you.

So allocate a copy of the address. You can do this e.g. with g_memdup. If
address->sa_family is AF_INET, you'll have sizeof(struct sockaddr_in) bytes to
allocate & copy, if it's AF_INET6, and you'll have sizeof(struct sockaddr_in6)
bytes instead.

And remember to free your address copy when the context goes away!

-- 
Configure bugmail: https://bugs.freedesktop.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA Contact for the bug.



More information about the telepathy-bugs mailing list