1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00

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
This commit is contained in:
Peter Rajnoha 2013-08-15 12:23:49 +02:00
parent 8cbbe851a8
commit 0563bd0037
4 changed files with 7 additions and 13 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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[],

View File

@ -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;
}