Unverified Commit ba2861ff by Stéphane Graber Committed by GitHub

Merge pull request #2144 from brauner/2018-02-08/coverity_bug_smash

coverity: bug smash
parents 056fec39 287df277
...@@ -523,6 +523,8 @@ static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char ** ...@@ -523,6 +523,8 @@ static bool find_hierarchy_mountpts( struct cgroup_meta_data *meta_data, char **
} }
} }
lxc_free_array((void **)subsystems, free); lxc_free_array((void **)subsystems, free);
if (!h)
goto out;
r = lxc_grow_array((void ***)&meta_data->mount_points, &mount_point_capacity, mount_point_count + 1, 12); r = lxc_grow_array((void ***)&meta_data->mount_points, &mount_point_capacity, mount_point_count + 1, 12);
if (r < 0) if (r < 0)
......
...@@ -1143,6 +1143,7 @@ static bool cg_hybrid_init(void) ...@@ -1143,6 +1143,7 @@ static bool cg_hybrid_init(void)
f = fopen("/proc/self/mountinfo", "r"); f = fopen("/proc/self/mountinfo", "r");
if (!f) { if (!f) {
CGFSNG_DEBUG("Failed to open \"/proc/self/mountinfo\"\n"); CGFSNG_DEBUG("Failed to open \"/proc/self/mountinfo\"\n");
free(basecginfo);
return false; return false;
} }
......
...@@ -2727,7 +2727,7 @@ static bool container_destroy(struct lxc_container *c, ...@@ -2727,7 +2727,7 @@ static bool container_destroy(struct lxc_container *c,
if (conf && !lxc_list_empty(&conf->hooks[LXCHOOK_DESTROY])) { if (conf && !lxc_list_empty(&conf->hooks[LXCHOOK_DESTROY])) {
/* Start of environment variable setup for hooks */ /* Start of environment variable setup for hooks */
if (c->name && setenv("LXC_NAME", c->name, 1)) if (setenv("LXC_NAME", c->name, 1))
SYSERROR("Failed to set environment variable for container name"); SYSERROR("Failed to set environment variable for container name");
if (conf->rcfile && setenv("LXC_CONFIG_FILE", conf->rcfile, 1)) if (conf->rcfile && setenv("LXC_CONFIG_FILE", conf->rcfile, 1))
...@@ -3425,7 +3425,7 @@ static int clone_update_rootfs(struct clone_update_data *data) ...@@ -3425,7 +3425,7 @@ static int clone_update_rootfs(struct clone_update_data *data)
if (c0->name && setenv("LXC_SRC_NAME", c0->name, 1)) { if (c0->name && setenv("LXC_SRC_NAME", c0->name, 1)) {
SYSERROR("failed to set environment variable for source container name"); SYSERROR("failed to set environment variable for source container name");
} }
if (c->name && setenv("LXC_NAME", c->name, 1)) { if (setenv("LXC_NAME", c->name, 1)) {
SYSERROR("failed to set environment variable for container name"); SYSERROR("failed to set environment variable for container name");
} }
if (conf->rcfile && setenv("LXC_CONFIG_FILE", conf->rcfile, 1)) { if (conf->rcfile && setenv("LXC_CONFIG_FILE", conf->rcfile, 1)) {
......
...@@ -239,7 +239,6 @@ int lxc_monitor_open(const char *lxcpath) ...@@ -239,7 +239,6 @@ int lxc_monitor_open(const char *lxcpath)
if (fd < 0) { if (fd < 0) {
ERROR("Failed to connect to monitor socket: %s.", strerror(errno)); ERROR("Failed to connect to monitor socket: %s.", strerror(errno));
close(fd);
return -1; return -1;
} }
......
...@@ -1660,14 +1660,17 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1660,14 +1660,17 @@ static int lxc_spawn(struct lxc_handler *handler)
DEBUG("Preserved cgroup namespace via fd %d", ret); DEBUG("Preserved cgroup namespace via fd %d", ret);
} }
snprintf(pidstr, 20, "%d", handler->pid); ret = snprintf(pidstr, 20, "%d", handler->pid);
if (ret < 0 || ret >= 20)
goto out_delete_net;
if (setenv("LXC_PID", pidstr, 1)) if (setenv("LXC_PID", pidstr, 1))
SYSERROR("Failed to set environment variable: LXC_PID=%s.", pidstr); SYSERROR("Failed to set environment variable: LXC_PID=%s.", pidstr);
/* Run any host-side start hooks */ /* Run any host-side start hooks */
if (run_lxc_hooks(name, "start-host", conf, NULL)) { if (run_lxc_hooks(name, "start-host", conf, NULL)) {
ERROR("Failed to run lxc.hook.start-host for container \"%s\".", name); ERROR("Failed to run lxc.hook.start-host for container \"%s\".", name);
return -1; goto out_delete_net;
} }
/* Tell the child to complete its initialization and wait for it to exec /* Tell the child to complete its initialization and wait for it to exec
...@@ -1677,7 +1680,7 @@ static int lxc_spawn(struct lxc_handler *handler) ...@@ -1677,7 +1680,7 @@ static int lxc_spawn(struct lxc_handler *handler)
* value, causing us to error out). * value, causing us to error out).
*/ */
if (lxc_sync_barrier_child(handler, LXC_SYNC_READY_START)) if (lxc_sync_barrier_child(handler, LXC_SYNC_READY_START))
return -1; goto out_delete_net;
if (lxc_network_recv_name_and_ifindex_from_child(handler) < 0) { if (lxc_network_recv_name_and_ifindex_from_child(handler) < 0) {
ERROR("Failed to receive names and ifindices for network " ERROR("Failed to receive names and ifindices for network "
......
...@@ -56,7 +56,7 @@ void *ns_sharing_wrapper(void *data) ...@@ -56,7 +56,7 @@ void *ns_sharing_wrapper(void *data)
c = lxc_container_new(name, NULL); c = lxc_container_new(name, NULL);
if (!c) { if (!c) {
lxc_error("Failed to create container \"%s\"\n", name); lxc_error("Failed to create container \"%s\"\n", name);
goto out; return NULL;
} }
if (c->is_defined(c)) { if (c->is_defined(c)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment