lib/libadmin/util.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
New commits:
commit 5a52f43e2ecc5cdad7bf4b2916688ee42095fe88
Author: Nathan Kinder <nkinder(a)redhat.com>
Date: Fri Apr 29 11:31:19 2011 -0700
Bug 700890 - (cov#10812) Check return value of open() properly in libadmin
We do not properly check the return value of open() in the run_cmd()
function in libadmin. The open() function will return -1 if the open
failed. The if condition needs to check if the return value is < 0 so
it can bail out properly.
diff --git a/lib/libadmin/util.c b/lib/libadmin/util.c
index 4b8f326..bfb7354 100644
--- a/lib/libadmin/util.c
+++ b/lib/libadmin/util.c
@@ -481,7 +481,7 @@ int run_cmd(char *cmd, FILE *closeme, struct runcmd_s *rm)
return -1;
}
if(exstat) {
- if(!(fd = open(tfn, O_RDONLY))) {
+ if((fd = open(tfn, O_RDONLY)) < 0) {
rm->title = "Can't open error file";
rm->msg = "Can't find error file %s.";
rm->arg = cmd;
Show replies by thread