]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
login: ensure getutxid() does not use uninitialized variable [coverity scan]
authorSami Kerola <kerolasa@iki.fi>
Sat, 8 Aug 2020 19:06:42 +0000 (20:06 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 16 Oct 2020 09:30:45 +0000 (11:30 +0200)
Field ut.ut_pid is uninitialized when calling getutxline().  The safest
option is to ensure all struct data is initialized in the function.

CID: 360793
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
login-utils/login.c

index 5cd77acf4ba4e20b097adb6e0defa3021a47ad86..e2eb108024e1ea627b6b3a04a0c2802040de4a84 100644 (file)
@@ -698,9 +698,9 @@ done:
  */
 static void log_utmp(struct login_context *cxt)
 {
-       struct utmpx ut;
-       struct utmpx *utp;
-       struct timeval tv;
+       struct utmpx ut = {0};
+       struct utmpx *utp = NULL;
+       struct timeval tv = {0};
 
        utmpxname(_PATH_UTMP);
        setutxent();