cpw.darkrain42.xmpp.bosh: d9471e1c: First crack at Win32 TXT DNS query code ...

paul at darkrain42.org paul at darkrain42.org
Sat Apr 11 19:05:48 EDT 2009


-----------------------------------------------------------------
Revision: d9471e1c592f9cd3e25d4ff182665758cc3da445
Ancestor: 04173b892c883ee04fd7be9731fa6d03be8978c3
Author: paul at darkrain42.org
Date: 2009-04-11T20:31:19
Branch: im.pidgin.cpw.darkrain42.xmpp.bosh
URL: http://d.pidgin.im/viewmtn/revision/info/d9471e1c592f9cd3e25d4ff182665758cc3da445

Modified files:
        libpurple/dnssrv.c libpurple/dnssrv.h
        libpurple/protocols/jabber/jabber.c

ChangeLog: 

First crack at Win32 TXT DNS query code and don't leak the PurpleTxtResponses

-------------- next part --------------
============================================================
--- libpurple/dnssrv.c	1074cb704934fbbb5291140b32096c006bc22c8a
+++ libpurple/dnssrv.c	d7b4c6b3fd803d6f86f1c97411aa2b6f67ed2957
@@ -183,7 +183,7 @@ resolve(int in, int out)
 			ret = g_list_insert_sorted(ret, srvres, responsecompare);
 		} else if (query.type == T_TXT) {
 			txtres = g_new0(PurpleTxtResponse, 1);
-			strncpy(txtres->content, (gchar*)(++cp), dlen-1);
+			txtres->content = g_strndup((gchar*)(++cp), dlen-1);
 			ret = g_list_append(ret, txtres);
 			cp += dlen - 1;
 		} else {
@@ -389,7 +389,33 @@ res_thread(gpointer data)
 			MyDnsRecordListFree(dr, DnsFreeRecordList);
 			query_data->results = lst;
 		} else if (type == T_TXT) {
-			#error IMPLEMENTATION MISSING		
+			PDNS_RECORD dr_tmp;
+			GSList *lst = NULL;
+			DNS_TXT_DATA *txt_data;
+			PurpleTxtResponse *txtres;
+
+			for (dr_tmp = dr; dr_tmp != NULL; dr_tmp = dr_tmp->pNext) {
+				GString *s;
+				int i;
+
+				/* Discard any incorrect entries. I'm not sure if this is necessary */
+				if (dr_tmp->wType != type || strcmp(dr_tmp->pName, query_data->query) != 0) {
+					continue;
+				}
+
+				txt_data = &dr_tmp->Data.TXT;
+				txtres = g_new0(PurpleTxtResponse, 1);
+
+				s = g_string_new("");
+				for (i = 0; i < txt_data->dwStringCount; ++i)
+					s = g_string_append(s, txt_data->pStringArray[i]);
+				txtres->content = g_string_free(s, FALSE);
+
+				lst = g_slist_append(lst, txtres);
+			}
+
+			MyDnsRecordListFree(dr, DnsFreeRecordList);
+			query_data->results = lst;
 		} else {
 			
 		}
============================================================
--- libpurple/dnssrv.h	56f31b291960894348165acfcc7731bfe4c24204
+++ libpurple/dnssrv.h	56d16a20798f296adf3349135351db73a5c49632
@@ -40,7 +40,7 @@ struct _PurpleTxtResponse {
 };
 
 struct _PurpleTxtResponse {
-    char content[256];
+    char *content;
 };
 
 typedef void (*PurpleSrvCallback)(PurpleSrvResponse *resp, int results, gpointer data);
============================================================
--- libpurple/protocols/jabber/jabber.c	1554bd3f7385a5575267fae9455cf3f667e73062
+++ libpurple/protocols/jabber/jabber.c	1d88f1b0990414b8136a0288dfca5f7045520329
@@ -617,6 +617,11 @@ txt_resolved_cb(PurpleTxtResponse *resp,
 	} else {
 		purple_debug_info("jabber","Didn't find an alternative connection method.\n");
 	}
+
+	for (n = 0; n < results; ++n)
+		g_free(resp[n].content);
+
+	g_free(resp);
 }
 
 static void


More information about the Commits mailing list