From 2356507f89c5574641b7db0eee6d47bec131e69b Mon Sep 17 00:00:00 2001 From: Ray Strode Date: Dec 01 2009 16:04:53 +0000 Subject: - Don't crash if /etc/passwd contains invalid utf8 (bug 539737) --- diff --git a/dont-crash-with-invalid-utf8.patch b/dont-crash-with-invalid-utf8.patch new file mode 100644 index 0000000..f44daad --- /dev/null +++ b/dont-crash-with-invalid-utf8.patch @@ -0,0 +1,63 @@ +From 8b8521dd83637d4e83d67adddefba4f30c99715c Mon Sep 17 00:00:00 2001 +From: Takao Fujiwara +Date: Thu, 22 Oct 2009 15:20:49 +0900 +Subject: [PATCH] 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; + } +-- +1.6.5.2 + diff --git a/gdm.spec b/gdm.spec index 5420bdd..03abc0a 100644 --- a/gdm.spec +++ b/gdm.spec @@ -16,7 +16,7 @@ Summary: The GNOME Display Manager Name: gdm Version: 2.28.1 -Release: 24%{?dist} +Release: 25%{?dist} Epoch: 1 License: GPLv2+ Group: User Interface/X @@ -109,6 +109,8 @@ Patch25: fix-run-dir-permissions.patch Patch26: make-user-list-animation-smoother.patch Patch27: 0001-Don-t-show-lock-screen-option-if-locked-down.patch Patch28: hide-search-entry.patch +# http://bugzilla.redhat.com/539737 +Patch29: dont-crash-with-invalid-utf8.patch Patch96: gdm-multistack.patch Patch100: gdm-2.28.1-eviction-notice.patch @@ -165,6 +167,7 @@ The GDM fingerprint plugin provides functionality necessary to use a fingerprint %patch26 -p1 -b .make-user-list-animation-smoother %patch27 -p1 -b .dont-show-lock-screen-if-locked-down %patch28 -p1 -b .hide-search-entry +%patch29 -p1 -b .dont-crash-with-invalid-utf8 %patch96 -p1 -b .multistack %patch100 -p1 -b .eviction-notice @@ -423,6 +426,9 @@ fi %{_libdir}/gdm/simple-greeter/plugins/fingerprint.so %changelog +* Tue Dec 01 2009 Ray Strode 2.28.1-25 +- Don't crash if /etc/passwd contains invalid utf8 (bug 539737) + * Fri Nov 06 2009 Ray Strode 2.28.1-24 - Fix login button after cancel on livecd