Skip to contentSkip to conversation

login: remove file descriptor leak [cppcheck]

PATCH Applied Sami Kerola 2 participants 2 messages Feb 20, 2013 – Mar 4, 2013 Util-Linux package

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 login: remove file descriptor leak [cppcheck]

[login-utils/login.c:510]: (error) Resource leak: fd

---
 login-utils/login.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
login-utils/login.c +3 -1
index a17083b..4250534 100644
@@ -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
maintainer Applied
#1 lore raw
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