From: Bruno Haible Date: Fri, 15 Sep 2023 15:40:10 +0000 (+0200) Subject: readutmp: Fix crash when gdm is in use. X-Git-Tag: v1.0~781 X-Git-Url: https://gitweb.git.savannah.gnu.org/gitweb/?a=commitdiff_plain;h=579f2d6f3d1d817c2f7e2c603c9a3ded63dcaa92;p=gnulib.git readutmp: Fix crash when gdm is in use. Reported by Thorsten Kukuk in . * lib/readutmp.c (read_utmp_from_systemd): Don't use the value returned by sd_session_get_display if it is NULL. --- diff --git a/ChangeLog b/ChangeLog index 2e6be08050..adeb01b624 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2023-09-15 Bruno Haible + + readutmp: Fix crash when gdm is in use. + Reported by Thorsten Kukuk in + . + * lib/readutmp.c (read_utmp_from_systemd): Don't use the value returned + by sd_session_get_display if it is NULL. + 2023-09-14 Bruno Haible doc: Mention libucontext. diff --git a/lib/readutmp.c b/lib/readutmp.c index ec09feb59b..d8213e7ad5 100644 --- a/lib/readutmp.c +++ b/lib/readutmp.c @@ -873,7 +873,10 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options) char *display; if (sd_session_get_display (session, &display) < 0) display = NULL; - host = display; + /* Workaround: gdm "forgets" to pass the display to + systemd, thus display may be NULL here. */ + if (display != NULL) + host = display; } } else