changeset 16789:a9975d6c2832

The last name from /etc/passwd may have additional comma-delimited data which we should ignore when determining the default Bonjour name. Fixes #477
author Evan Schoenberg <evan.s@dreskin.net>
date Wed, 02 May 2007 11:54:27 +0000
parents 9a2ec0a033b5
children e3f4f1fd8f3d
files libpurple/protocols/bonjour/bonjour.c
diffstat 1 files changed, 11 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/protocols/bonjour/bonjour.c	Wed May 02 00:56:11 2007 +0000
+++ b/libpurple/protocols/bonjour/bonjour.c	Wed May 02 11:54:27 2007 +0000
@@ -460,6 +460,7 @@
 	const char *fullname = NULL;
 #endif
 	char *splitpoint = NULL;
+	char *tmp;
 	char hostname[255];
 
 #ifndef _WIN32
@@ -545,7 +546,16 @@
 	if (splitpoint != NULL)
 	{
 		default_firstname = g_strndup(fullname, splitpoint - fullname);
-		default_lastname = g_strdup(&splitpoint[1]);
+		tmp = &splitpoint[1];
+		
+		/* The last name may be followed by a comma and additional data.
+		 * Only use the last name itself.
+		 */
+		splitpoint = strchr(tmp, ',');
+		if (splitpoint != NULL)
+			default_lastname = g_strndup(tmp, splitpoint - tmp);			
+		else
+			default_lastname = g_strdup(tmp);
 	}
 	else
 	{