[gdm/gnome-2-28] Fix real names not to crash greeter. Bug #594270
- From: Brian Cameron <bcameron src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gdm/gnome-2-28] Fix real names not to crash greeter. Bug #594270
- Date: Wed, 16 Dec 2009 22:53:25 +0000 (UTC)
commit 7559abbbda10b5a2db72a5469ee1467f0086f188
Author: Brian Cameron <Brian Cameron sun com>
Date: Wed Dec 16 16:52:42 2009 -0600
Fix real names not to crash greeter. Bug #594270
Reviewed by Ray Strode
gui/simple-greeter/gdm-user.c | 26 +++++++++++++++++---------
1 files changed, 17 insertions(+), 9 deletions(-)
---
diff --git a/gui/simple-greeter/gdm-user.c b/gui/simple-greeter/gdm-user.c
index 79d8628..31ae696 100644
--- a/gui/simple-greeter/gdm-user.c
+++ b/gui/simple-greeter/gdm-user.c
@@ -415,7 +415,7 @@ void
_gdm_user_update (GdmUser *user,
const struct passwd *pwent)
{
- gchar *real_name;
+ gchar *real_name = NULL;
g_return_if_fail (GDM_IS_USER (user));
g_return_if_fail (pwent != NULL);
@@ -424,20 +424,28 @@ _gdm_user_update (GdmUser *user,
/* Display Name */
if (pwent->pw_gecos && pwent->pw_gecos[0] != '\0') {
- gchar *first_comma;
- gchar *real_name_utf8;
+ gchar *first_comma = NULL;
+ gchar *valid_utf8_name = NULL;
- real_name_utf8 = g_locale_to_utf8 (pwent->pw_gecos, -1, NULL, NULL, NULL);
+ if (g_utf8_validate (pwent->pw_gecos, -1, NULL)) {
+ valid_utf8_name = pwent->pw_gecos;
+ first_comma = g_utf8_strchr (valid_utf8_name, -1, ',');
+ } else {
+ g_warning ("User %s has invalid UTF-8 in GECOS field. "
+ "It would be a good thing to check /etc/passwd.",
+ pwent->pw_name ? pwent->pw_name : "");
+ }
- first_comma = strchr (real_name_utf8, ',');
if (first_comma) {
- real_name = g_strndup (real_name_utf8, first_comma - real_name_utf8);
- g_free (real_name_utf8);
+ real_name = g_strndup (valid_utf8_name,
+ (first_comma - valid_utf8_name));
+ } else if (valid_utf8_name) {
+ real_name = g_strdup (valid_utf8_name);
} else {
- real_name = real_name_utf8;
+ real_name = NULL;
}
- if (real_name[0] == '\0') {
+ if (real_name && real_name[0] == '\0') {
g_free (real_name);
real_name = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]