changeset 25595:94c8bef52c66

* some further bugfixing, BIND's libresolv does so much for the programmer, just happy it exists
author Tobias Markmann <tfar@soc.pidgin.im>
date Sat, 02 Aug 2008 16:43:04 +0000
parents 3c3480683075
children 7768cad83127
files libpurple/dnssrv.c
diffstat 1 files changed, 4 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/dnssrv.c	Fri Aug 01 22:37:51 2008 +0000
+++ b/libpurple/dnssrv.c	Sat Aug 02 16:43:04 2008 +0000
@@ -122,6 +122,7 @@
 	gchar name[256];
 	guint16 type, dlen, pref, weight, port;
 	PurpleSrvInternalQuery query;
+	int n;
 
 #ifdef HAVE_SIGNAL_H
 	purple_restore_default_signal_handlers();
@@ -134,10 +135,9 @@
 	}
 
 	size = res_query( query.query, C_IN, query.type, (u_char*)&answer, sizeof( answer));
-
+	
 	qdcount = ntohs(answer.hdr.qdcount);
 	ancount = ntohs(answer.hdr.ancount);
-
 	cp = (guchar*)&answer + sizeof(HEADER);
 	end = (guchar*)&answer + size;
 
@@ -152,16 +152,13 @@
 		size = dn_expand((unsigned char*)&answer, end, cp, name, 256);
 		if(size < 0)
 			goto end;
-
 		cp += size;
-
 		GETSHORT(type,cp);
 
 		/* skip ttl and class since we already know it */
 		cp += 6;
 
 		GETSHORT(dlen,cp);
-
 		if (query.type == T_SRV) {
 			GETSHORT(pref,cp);
 
@@ -183,13 +180,10 @@
 
 			ret = g_list_insert_sorted(ret, srvres, responsecompare);
 		} else if (query.type == T_TXT) {
-			size = dn_expand( (unsigned char*)&answer, end, cp, name, 256);
-			if(size < 0 )
-				goto end;
 			txtres = g_new0(PurpleTxtResponse, 1);
-			strcpy(txtres->content, name);
-			
+			strncpy(txtres->content, ++cp, dlen-1);
 			ret = g_list_append(ret, txtres);
+			cp += dlen - 1;
 		} else {
 			cp += dlen;
 		}