* [PATCH] login: remove file descriptor leak [cppcheck]
@ 2013-02-20 21:31 Sami Kerola
2013-03-04 11:31 ` Karel Zak
0 siblings, 1 reply; 2+ messages in thread
From: Sami Kerola @ 2013-02-20 21:31 UTC (permalink / raw)
To: util-linux; +Cc: kerolasa
[login-utils/login.c:510]: (error) Resource leak: fd
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
---
login-utils/login.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/login-utils/login.c b/login-utils/login.c
index a17083b..4250534 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -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
--
1.8.1.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-03-04 11:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-20 21:31 [PATCH] login: remove file descriptor leak [cppcheck] Sami Kerola
2013-03-04 11:31 ` Karel Zak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox