Module: monitoring-plugins
    Branch: master
    Commit: 9123f6146c5dd3285d8fb78cf3a8cd52bad17ec1
    Author: Spenser Reinhardt <[email protected]>
 Committer: Jan Wagner <[email protected]>
      Date: Mon Jun 23 13:54:39 2014 -0500
       URL: 
https://www.monitoring-plugins.org/repositories/monitoring-plugins/commit/?id=9123f61

lib/utils_cmd.c - Free file descriptor

Coverity 66502 - File descriptor fd in cmd_file_read is never closed, and thus 
file is left open after usage throughout runtime. - SR

---

 lib/utils_cmd.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/utils_cmd.c b/lib/utils_cmd.c
index 4c6d0be..9e214bd 100644
--- a/lib/utils_cmd.c
+++ b/lib/utils_cmd.c
@@ -390,6 +390,9 @@ cmd_file_read ( char *filename, output *out, int flags)
        
        if(out)
                out->lines = _cmd_fetch_output (fd, out, flags);
+       
+       if (close(fd) == -1)
+               die( STATE_UNKNOWN, _("Error closing %s: %s"), filename, 
strerror(errno) );
 
        return 0;
 }

Reply via email to