From a5cb3677cff6d2e1246dbc13962ca9e788c6338b Mon Sep 17 00:00:00 2001 From: Alessandro Bono Date: Thu, 29 Sep 2022 11:26:45 +0200 Subject: gdm-display-access-file: Check _get_uid_and_gid_for_user() return value While it is unlikely that the gdm user is not installed on the system, check the returning value of _get_uid_and_gid_for_user(), so that we are not going to read a garbage value from the gid variable. --- daemon/gdm-display-access-file.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'daemon/gdm-display-access-file.c') diff --git a/daemon/gdm-display-access-file.c b/daemon/gdm-display-access-file.c index 36258a11..ed0a146d 100644 --- a/daemon/gdm-display-access-file.c +++ b/daemon/gdm-display-access-file.c @@ -278,7 +278,15 @@ _create_xauth_file_for_user (const char *username, } g_chmod (GDM_XAUTH_DIR, 0711); - _get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid); + if (!_get_uid_and_gid_for_user (GDM_USERNAME, &uid, &gid)) { + g_set_error (error, + GDM_DISPLAY_ERROR, + GDM_DISPLAY_ERROR_GETTING_USER_INFO, + _("Could not find user ā€œ%sā€ on system"), + GDM_USERNAME); + goto out; + } + if (chown (GDM_XAUTH_DIR, 0, gid) != 0) { g_warning ("Unable to change owner of '%s'", GDM_XAUTH_DIR); -- cgit v1.2.1