login: remove file descriptor leak [cppcheck]
PATCH 1/1 login: remove file descriptor leak [cppcheck]
[login-utils/login.c:510]: (error) Resource leak: fd
Signed-off-by Sami Kerola <[email protected]>
--- login-utils/login.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
login-utils/login.c +3 -1
@@ -506,8 +506,10 @@ static void log_lastlog(struct login_context *cxt)if (fd <0 )return ; -if (lseek (fd, (off_t ) cxt->pwd->pw_uid *sizeof (ll),SEEK_SET ) ==-1 ) +if (lseek (fd, (off_t ) cxt->pwd->pw_uid *sizeof (ll),SEEK_SET ) ==-1 ) { +close (fd);return ; + }/* * Print last log message
Signature · 1 line
1.8.1.4
Quoted 2 lines · Sami Kerola
login-utils/login.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Applied, thanks.
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com