[icinga-checkins] icinga.org: icinga-core/master: fix open() error checking in move_check_result_to_queue() (Andreas Ericsson)

git at icinga.org git at icinga.org
Wed May 19 13:41:53 CEST 2010


Module: icinga-core
Branch: master
Commit: 8d39c495624fffd3b527557d95fb44a17aad2f3f
URL:    https://git.icinga.org/?p=icinga-core.git;a=commit;h=8d39c495624fffd3b527557d95fb44a17aad2f3f

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

fix open() error checking in move_check_result_to_queue() (Andreas Ericsson)

[--snip--]
Previously we used to check that open() returned > 0, which isn't
correct. open() can validly return 0 on success, so make the
close() call conditional on open() return >= 0 to plug the
potential file-descriptor leak.
[--snip--]

fixes #426

---

 Changelog    |    1 +
 base/utils.c |    2 +-
 2 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/Changelog b/Changelog
index 51df230..9610149 100644
--- a/Changelog
+++ b/Changelog
@@ -44,6 +44,7 @@ FIXES
 * core: base/commands.c: Fix error path of opening checkresult files (Andreas Ericsson)
 * core: base/nebmods.c: Replace local file-copy hack with my_fcopy() (Andreas Ericsson)
 * core: enable compiler flag -Wall by default (base/cgi/common/idoutils)
+* core: fix open() error checking in move_check_result_to_queue() (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/base/utils.c b/base/utils.c
index 5e4d209..ec1d929 100644
--- a/base/utils.c
+++ b/base/utils.c
@@ -2143,7 +2143,7 @@ int move_check_result_to_queue(char *checkresult_file){
 
 		/* create an ok-to-go indicator file */
 		asprintf(&temp_buffer,"%s.ok",output_file);
-		if((output_file_fd=open(temp_buffer,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR))>0)
+		if((output_file_fd=open(temp_buffer,O_CREAT|O_WRONLY|O_TRUNC,S_IRUSR|S_IWUSR))>=0)
 			close(output_file_fd);
 		my_free(temp_buffer);
 





More information about the icinga-checkins mailing list