master - fix: some issues reported by coverity
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=0563bd0037610397c5838d0172fd1c913c62c187 Commit: 0563bd0037610397c5838d0172fd1c913c62c187 Parent: 8cbbe851a80e8d99dc886ce9b44834137731d8ce Author: Peter Rajnoha <[email protected]> AuthorDate: Thu Aug 15 12:23:49 2013 +0200 Committer: Peter Rajnoha <[email protected]> CommitterDate: Thu Aug 15 12:23:49 2013 +0200
fix: some issues reported by coverity
- null_fd resource leak on error path in _reopen_fd_null fn
- dead code in verify_message in clvmd code
- dead code in _init_filter_components in toolcontext code
- null dereference in dm_prepare_selinux_context on error path if setfscreatecon fails while resetting SELinux context
--- daemons/clvmd/clvmd.c | 5 ----- lib/commands/toolcontext.c | 4 ---- lib/misc/lvm-exec.c | 9 ++++++--- libdm/libdm-common.c | 2 +- 4 files changed, 7 insertions(+), 13 deletions(-)
daemons/clvmd/clvmd.c +0 -5
@@ -1133,11 +1133,6 @@ static int verify_message(char *buf, int len)return -1 ; } -if (h->clientid <0 ) { -log_error ("verify_message bad clientid %x" , h->clientid); -return -1 ; - } -if (h->arglen > max_cluster_message) {log_error ("verify_message bad arglen %x max %d" , h->arglen, max_cluster_message);return -1 ;
lib/commands/toolcontext.c +0 -4
@@ -879,10 +879,6 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd) nr_filt++; } -/* Only build a composite filter if we really need it. */ -if (nr_filt ==1 ) -return filters[0 ]; -if (!(composite =composite_filter_create (nr_filt, filters))) goto_bad;
lib/misc/lvm-exec.c +6 -3
@@ -111,6 +111,7 @@ int exec_cmd(struct cmd_context *cmd, const char *const argv[],static int _reopen_fd_to_null (int fd) {int null_fd; +int r =0 ;if ((null_fd =open ("/dev/null" ,O_RDWR )) ==-1 ) {log_sys_error ("open" ,"/dev/null" );
@@ -119,20 +120,22 @@ static int _reopen_fd_to_null(int fd)if (close (fd)) {log_sys_error ("close" ,"" ); -return 0 ; + goto out; }if (dup2 (null_fd, fd) ==-1 ) {log_sys_error ("dup2" ,"" ); -return 0 ; + goto out; } + r =1 ; +out:if (close (null_fd)) {log_sys_error ("dup2" ,"" );return 0 ; } -return 1 ; +return r; } FILE *pipe_open(struct cmd_context *cmd, const char *const argv[],
libdm/libdm-common.c +1 -1
@@ -880,7 +880,7 @@ int dm_prepare_selinux_context(const char *path, mode_t mode)log_debug_activation ("Resetting SELinux context to default value." );if (setfscreatecon (scontext) <0 ) { -log_sys_error ("setfscreatecon" , path); +log_sys_error ("setfscreatecon" , path ? :"SELinux context reset" );freecon (scontext);return 0 ; }