im.pidgin.pidgin: f6e17bf35872d70d9ebba4cf860470a5b21d54ce

markdoliner at pidgin.im markdoliner at pidgin.im
Mon Jan 28 00:35:59 EST 2008


-----------------------------------------------------------------
Revision: f6e17bf35872d70d9ebba4cf860470a5b21d54ce
Ancestor: bb2d5971698f82249a6cf7e38e4a4d0a8aa97279
Author: markdoliner at pidgin.im
Date: 2008-01-28T05:31:28
Branch: im.pidgin.pidgin

Modified files:
        libpurple/protocols/bonjour/bonjour.c

ChangeLog: 

>From the gethostname() man page:
"In case the null-terminated hostname does not fit, no error is
returned, but the hostname is truncated. It is unspecified whether
the truncated hostname will be null-terminated."

-------------- next part --------------
============================================================
--- libpurple/protocols/bonjour/bonjour.c	a532ad0424ce6c64941869d07dbccf1e82e234e2
+++ libpurple/protocols/bonjour/bonjour.c	193d7ec7ffc3265767b73922ece594d556189bef
@@ -673,11 +673,12 @@ initialize_default_account_values(void)
 
 	/* Try to figure out a good host name to use */
 	/* TODO: Avoid 'localhost,' if possible */
-	if (gethostname(hostname, 255) != 0) {
+	if (gethostname(hostname, sizeof(hostname)) != 0) {
 		purple_debug_warning("bonjour", "Error when getting host name: %s.  Using \"localhost.\"\n",
 				g_strerror(errno));
 		strcpy(hostname, "localhost");
 	}
+	hostname[sizeof(hostname) - 1] = '\0';
 	default_hostname = g_strdup(hostname);
 }
 


More information about the Commits mailing list