From: Iker Pedrosa Date: Fri, 15 Sep 2023 07:55:02 +0000 (+0200) Subject: utmp: call prepare_utmp() even if utent is NULL X-Git-Tag: 4.15.0-rc1~176 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=5178f8c5afb612f6ddf5363823547e080e7f546b;p=thirdparty%2Fshadow.git utmp: call prepare_utmp() even if utent is NULL update_utmp() should also return 0 when success. Fixes: 1f368e1c1838de9d476a36897d7c53394569de08 ("utmp: update `update_utmp()") Resolves: https://github.com/shadow-maint/shadow/issues/805 Signed-off-by: Iker Pedrosa --- diff --git a/lib/utmp.c b/lib/utmp.c index 9b173327a..e0ae48a08 100644 --- a/lib/utmp.c +++ b/lib/utmp.c @@ -370,17 +370,16 @@ int update_utmp (const char *user, struct utmp *utent, *ut; utent = get_current_utmp (); - if (utent == NULL) { - return -1; - } - ut = prepare_utmp (user, tty, host, utent); (void) setutmp (ut); /* make entry in the utmp & wtmp files */ - free (utent); + + if (utent != NULL) { + free (utent); + } free (ut); - return 1; + return 0; } void record_failure(const char *failent_user,