SHA256
1
0
forked from pool/coreutils
coreutils/gnulib-readutmp.patch
Bernhard Voelker b027767dc6 Accepting request 1111796 from home:berny:branches:Base:System
- gnulib-readutmp-under-gdm.patch: Add upstream gnulib patch to fix crash
  of who/uptime when gdm is in use. [bsc#1215361]
- gnulib-readutmp.patch: Update with upstream patch.

OBS-URL: https://build.opensuse.org/request/show/1111796
OBS-URL: https://build.opensuse.org/package/show/Base:System/coreutils?expand=0&rev=354
2023-09-20 07:05:48 +00:00

44 lines
1.4 KiB
Diff
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This squashes 2 consecutive upstream gnulib commits
to fix gnulib seg.faults if there is no session:
https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65617
Upstream gnulib commit 3af1d7b0ce3a8e3ae565e7cea10cee6fd7cb8109
2023-08-31 Bruno Haible <bruno@clisp.org>
readutmp: Fix memory leak introduced by last commit.
* lib/readutmp.c (read_utmp_from_systemd): If num_sessions == 0 and
sessions != NULL, do call free (sessions).
Upstream gnulib commit 1e6a26f9312bb47e070f94b17b14dc1a6ffbb74f
2023-08-30 Paul Eggert <eggert@cs.ucla.edu>
readutmp: fix core dump if --enable-systemd
Problem reported by Thorsten Kukuk <https://bugs.gnu.org/65617>.
* lib/readutmp.c (read_utmp_from_systemd):
Dont assume session_ptr != NULL if num_sessions == 0.
In practice it can be null, and the man page OKs this behavior.
---
lib/readutmp.c | 2 +-
1 files changed, 1 insertions(+), 1 deletion(-)
diff --git a/lib/readutmp.c b/lib/readutmp.c
index 0173b7e0c1..e99158677c 100644
--- a/lib/readutmp.c
+++ b/lib/readutmp.c
@@ -795,7 +795,7 @@ read_utmp_from_systemd (idx_t *n_entries, STRUCT_UTMP **utmp_buf, int options)
{
char **sessions;
int num_sessions = sd_get_sessions (&sessions);
- if (num_sessions >= 0)
+ if (num_sessions >= 0 && sessions != NULL)
{
char **session_ptr;
for (session_ptr = sessions; *session_ptr != NULL; session_ptr++)
--
2.42.0