From: Sami Kerola Date: Sat, 8 Aug 2020 19:06:42 +0000 (+0100) Subject: login: ensure getutxid() does not use uninitialized variable [coverity scan] X-Git-Tag: v2.36.1~24 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=bad223f0072de4ad2f7fbdfb0cc6836037aa4467;p=thirdparty%2Futil-linux.git login: ensure getutxid() does not use uninitialized variable [coverity scan] 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 --- diff --git a/login-utils/login.c b/login-utils/login.c index 186a5ff5e4..eaf5361712 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -635,9 +635,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();