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.37-rc1~411 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c60c65c37eb789410d8b1db1d55fc6c954f48e87;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 e2eb108024..37a52f6612 100644 --- a/login-utils/login.c +++ b/login-utils/login.c @@ -395,9 +395,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)