comparison libpurple/protocols/bonjour/bonjour.c @ 16778: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 1ac4039a2634
children 56042b2f8b64
comparison
equal deleted inserted replaced
16765:9a2ec0a033b5 16778:a9975d6c2832
458 #else 458 #else
459 struct passwd *info; 459 struct passwd *info;
460 const char *fullname = NULL; 460 const char *fullname = NULL;
461 #endif 461 #endif
462 char *splitpoint = NULL; 462 char *splitpoint = NULL;
463 char *tmp;
463 char hostname[255]; 464 char hostname[255];
464 465
465 #ifndef _WIN32 466 #ifndef _WIN32
466 /* Try to figure out the user's real name */ 467 /* Try to figure out the user's real name */
467 info = getpwuid(getuid()); 468 info = getpwuid(getuid());
543 /* Split the real name into a first and last name */ 544 /* Split the real name into a first and last name */
544 splitpoint = strchr(fullname, ' '); 545 splitpoint = strchr(fullname, ' ');
545 if (splitpoint != NULL) 546 if (splitpoint != NULL)
546 { 547 {
547 default_firstname = g_strndup(fullname, splitpoint - fullname); 548 default_firstname = g_strndup(fullname, splitpoint - fullname);
548 default_lastname = g_strdup(&splitpoint[1]); 549 tmp = &splitpoint[1];
550
551 /* The last name may be followed by a comma and additional data.
552 * Only use the last name itself.
553 */
554 splitpoint = strchr(tmp, ',');
555 if (splitpoint != NULL)
556 default_lastname = g_strndup(tmp, splitpoint - tmp);
557 else
558 default_lastname = g_strdup(tmp);
549 } 559 }
550 else 560 else
551 { 561 {
552 default_firstname = g_strdup(fullname); 562 default_firstname = g_strdup(fullname);
553 default_lastname = g_strdup(""); 563 default_lastname = g_strdup("");