pidgin: 53a62052: Save one traversal of the domain for IPv...

darkrain42 at pidgin.im darkrain42 at pidgin.im
Sat Jul 11 04:00:32 EDT 2009


-----------------------------------------------------------------
Revision: 53a6205270276533c2b97bad11b7b174891399ad
Ancestor: b5d595a88317436d663512f3773a8d65221ecb77
Author: darkrain42 at pidgin.im
Date: 2009-07-11T07:55:03
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/53a6205270276533c2b97bad11b7b174891399ad

Modified files:
        libpurple/protocols/jabber/jutil.c

ChangeLog: 

Save one traversal of the domain for IPv6 validation.

-------------- next part --------------
============================================================
--- libpurple/protocols/jabber/jutil.c	72853c7c8aa5c03fd177811a6bac57004b25857e
+++ libpurple/protocols/jabber/jutil.c	5fe1d61e21bbdf94452394f14657d757efa5c375
@@ -57,27 +57,28 @@ gboolean jabber_domain_validate(const ch
 gboolean jabber_domain_validate(const char *str)
 {
 	const char *c;
+	size_t len;
 
 	if(!str)
 		return TRUE;
 
-	if(strlen(str) > 1023)
+	len = strlen(str);
+	if (len > 1023)
 		return FALSE;
 
 	c = str;
 
 	if (*c == '[') {
 		/* Check if str is a valid IPv6 identifier */
-		const gchar *end_bracket = strstr(c, "]");
 		gboolean valid = FALSE;
 
-		if (!end_bracket || *(end_bracket + 1) != '\0')
+		if (*(c + len - 1) != ']')
 			return FALSE;
 
 		/* Ugly, but in-place */
-		*(gchar *)end_bracket = '\0';
+		*(gchar *)(c + len - 1) = '\0';
 		valid = purple_ipv6_address_is_valid(c + 1);
-		*(gchar *)end_bracket = ']';
+		*(gchar *)(c + len - 1) = ']';
 
 		return valid;
 	}


More information about the Commits mailing list