]> Savannah Git Hosting - gnulib.git/commitdiff
readutmp: Fix crash when gdm is in use.
authorBruno Haible <bruno@clisp.org>
Fri, 15 Sep 2023 15:40:10 +0000 (17:40 +0200)
committerBruno Haible <bruno@clisp.org>
Fri, 15 Sep 2023 15:40:10 +0000 (17:40 +0200)
Reported by Thorsten Kukuk <kukuk@suse.com> in
<https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00093.html>.

* lib/readutmp.c (read_utmp_from_systemd): Don't use the value returned
by sd_session_get_display if it is NULL.

ChangeLog
lib/readutmp.c

index 2e6be080502d803c6f9b723ab930b8c6206be33c..adeb01b62484b47fcddaa520de32e814e93ca42c 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2023-09-15  Bruno Haible  <bruno@clisp.org>
+
+       readutmp: Fix crash when gdm is in use.
+       Reported by Thorsten Kukuk <kukuk@suse.com> in
+       <https://lists.gnu.org/archive/html/bug-gnulib/2023-09/msg00093.html>.
+       * 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  <bruno@clisp.org>
 
        doc: Mention libucontext.
index ec09feb59b4dd01d26d7b364432648a7475f9528..d8213e7ad543a35848b5685f3c2eb645fb426a24 100644 (file)
@@ -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