From: Sami Kerola Date: Sun, 9 Aug 2020 12:34:00 +0000 (+0100) Subject: login: close() only a file descriptor that is open [coverity scan] X-Git-Tag: v2.36.1~23 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=8ae4eda9a3d53eb76f720e5b9bf165c5a46b369e;p=thirdparty%2Futil-linux.git login: close() only a file descriptor that is open [coverity scan] CID: 360819 Signed-off-by: Sami Kerola --- diff --git a/login-utils/login.c b/login-utils/login.c index eaf5361712..e531d0889c 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -335,9 +335,10 @@ static void motd(void) #endif if (S_ISREG(st.st_mode) && st.st_size > 0) { int fd = open(file, O_RDONLY, 0); - if (fd >= 0) + if (fd >= 0) { sendfile(fileno(stdout), fd, NULL, st.st_size); - close(fd); + close(fd); + } done++; } if (firstonly && done)