Blame SOURCES/sudo-1.9.7-utmp-leak.patch

e1791d
From 3fc3a07a03ef74fde99db40ce9ef43ccab336205 Mon Sep 17 00:00:00 2001
e1791d
From: MertsA <andrewmerts@gmail.com>
e1791d
Date: Fri, 23 Jul 2021 03:36:05 -0700
e1791d
Subject: [PATCH] Rewind utmp file pointer after searching for entry
e1791d
e1791d
getutline() advances the file pointer until it matches or reaches EOF. pututline() starts from the current position in utmp. This rewinds the file pointer to the beginning to avoid allocating additional spurious utmp entries.
e1791d
---
e1791d
 src/utmp.c | 1 +
e1791d
 1 file changed, 1 insertion(+)
e1791d
e1791d
diff --git a/src/utmp.c b/src/utmp.c
e1791d
index 544a37519..952bf3043 100644
e1791d
--- a/src/utmp.c
e1791d
+++ b/src/utmp.c
e1791d
@@ -210,6 +210,7 @@ utmp_login(const char *from_line, const char *to_line, int ttyfd,
e1791d
 	memset(&utbuf, 0, sizeof(utbuf));
e1791d
 	strncpy(utbuf.ut_line, from_line, sizeof(utbuf.ut_line));
e1791d
 	ut_old = sudo_getutline(&utbuf);
e1791d
+	sudo_setutent();
e1791d
     }
e1791d
     utmp_fill(to_line, user, ut_old, &utbuf);
e1791d
     if (sudo_pututline(&utbuf) != NULL)