[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] xl: valid fd can be 0 in main_loadpolicy
commit 8e36e4bab17319062c44902d5f7c44cc9493dc23 Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Mon Jul 27 18:45:05 2015 +0100 Commit: Ian Campbell <ian.campbell@xxxxxxxxxx> CommitDate: Tue Jul 28 11:53:19 2015 +0100 xl: valid fd can be 0 in main_loadpolicy Initialise polFd to -1 before hand to avoid closing 0 by accident. Also fixed some style problems while I was there. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Acked-by: Ian Campbell <ian.campbell@xxxxxxxxxx> --- tools/libxl/xl_cmdimpl.c | 8 ++++---- 1 files changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 74edf2c..9c19fbb 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -7851,7 +7851,7 @@ int main_setenforce(int argc, char **argv) int main_loadpolicy(int argc, char **argv) { const char *polFName; - int polFd = 0; + int polFd = -1; void *polMemCp = NULL; struct stat info; int ret; @@ -7863,7 +7863,7 @@ int main_loadpolicy(int argc, char **argv) polFName = argv[optind]; polFd = open(polFName, O_RDONLY); - if ( polFd < 0 ) { + if (polFd < 0) { fprintf(stderr, "Error occurred opening policy file '%s': %s\n", polFName, strerror(errno)); ret = -1; @@ -7871,7 +7871,7 @@ int main_loadpolicy(int argc, char **argv) } ret = stat(polFName, &info); - if ( ret < 0 ) { + if (ret < 0) { fprintf(stderr, "Error occurred retrieving information about" "policy file '%s': %s\n", polFName, strerror(errno)); goto done; @@ -7903,7 +7903,7 @@ int main_loadpolicy(int argc, char **argv) done: free(polMemCp); - if ( polFd > 0 ) + if (polFd >= 0) close(polFd); return ret; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |