[icinga-checkins] icinga.org: icinga-core/mfriedrich/core: xdata/xpddefault.c: Close perfdata files if fd's are >= 0 (Andreas Ericsson)

git at icinga.org git at icinga.org
Wed May 12 23:36:31 CEST 2010


Module: icinga-core
Branch: mfriedrich/core
Commit: 390ae04f2433e2142d34305b4fa89e906d1eae89
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=390ae04f2433e2142d34305b4fa89e906d1eae89

Author: Michael Friedrich <michael.friedrich at univie.ac.at>
Date:   Wed May 12 23:35:47 2010 +0200

xdata/xpddefault.c: Close perfdata files if fd's are >= 0 (Andreas Ericsson)

[--snip--]
Previously it used to be > 0, which would leak the filedescriptor
when open() validly returned 0.
[--snip--]

fixes #428

---

 Changelog          |    1 +
 xdata/xpddefault.c |    4 ++--
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/Changelog b/Changelog
index 75119c6..d9ca85f 100644
--- a/Changelog
+++ b/Changelog
@@ -46,6 +46,7 @@ FIXES
 * core: enable compiler flag -Wall by default (base/cgi/common/idoutils)
 * core: fix open() error checking in move_check_result_to_queue() (Andreas Ericsson)
 * core: base/utils.c: Refactor my_fcopy() (Andreas Ericsson)
+* core: xdata/xpddefault.c: Close perfdata files if fd's are >= 0 (Andreas Ericsson)
 
 * idoutils: Host DB inserts use string 'NULL\n' instead of NULL (William Preston)
 * idoutils: ndo2db_get_object_id fails to return existing IDs (William Preston)
diff --git a/xdata/xpddefault.c b/xdata/xpddefault.c
index 18e543f..df17c36 100644
--- a/xdata/xpddefault.c
+++ b/xdata/xpddefault.c
@@ -571,7 +571,7 @@ int xpddefault_close_host_perfdata_file(void){
 
 	if(xpddefault_host_perfdata_fp!=NULL)
 		fclose(xpddefault_host_perfdata_fp);
-	if(xpddefault_host_perfdata_fd>0){
+	if(xpddefault_host_perfdata_fd>=0){
 		close(xpddefault_host_perfdata_fd);
 		xpddefault_host_perfdata_fd=-1;
 		}
@@ -585,7 +585,7 @@ int xpddefault_close_service_perfdata_file(void){
 
 	if(xpddefault_service_perfdata_fp!=NULL)
 		fclose(xpddefault_service_perfdata_fp);
-	if(xpddefault_service_perfdata_fd>0){
+	if(xpddefault_service_perfdata_fd>=0){
 		close(xpddefault_service_perfdata_fd);
 		xpddefault_service_perfdata_fd=-1;
 		}





More information about the icinga-checkins mailing list