Unverified Commit fb398f07 by Stéphane Graber Committed by GitHub

Merge pull request #2007 from brauner/2017-12-06/bugfixes

coverity: bugfixes
parents 49be8a14 070a05af
......@@ -1388,7 +1388,7 @@ again:
ret = snprintf(offset, 5, "-%d", idx);
if (ret < 0 || (size_t)ret >= 5) {
FILE *f = fopen("/dev/null", "w");
if (f >= 0) {
if (f) {
fprintf(f, "Workaround for GCC7 bug: "
"https://gcc.gnu.org/bugzilla/"
"show_bug.cgi?id=78969");
......
......@@ -713,8 +713,12 @@ int set_config_network_legacy_ipv6(const char *key, const char *value,
if (slash) {
*slash = '\0';
netmask = slash + 1;
if (lxc_safe_uint(netmask, &inet6dev->prefix) < 0)
if (lxc_safe_uint(netmask, &inet6dev->prefix) < 0) {
free(list);
free(inet6dev);
free(valdup);
return -1;
}
}
if (!inet_pton(AF_INET6, valdup, &inet6dev->addr)) {
......
......@@ -4463,7 +4463,7 @@ WRAP_API_2(bool, lxcapi_detach_interface, const char *, const char *)
static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
struct migrate_opts *opts, unsigned int size)
{
int ret;
int ret = -1;
struct migrate_opts *valid_opts = opts;
/* If the caller has a bigger (newer) struct migrate_opts, let's make
......@@ -4500,21 +4500,21 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
case MIGRATE_PRE_DUMP:
if (!do_lxcapi_is_running(c)) {
ERROR("container is not running");
return false;
goto on_error;
}
ret = !__criu_pre_dump(c, valid_opts);
break;
case MIGRATE_DUMP:
if (!do_lxcapi_is_running(c)) {
ERROR("container is not running");
return false;
goto on_error;
}
ret = !__criu_dump(c, valid_opts);
break;
case MIGRATE_RESTORE:
if (do_lxcapi_is_running(c)) {
ERROR("container is already running");
return false;
goto on_error;
}
ret = !__criu_restore(c, valid_opts);
break;
......@@ -4523,6 +4523,7 @@ static int do_lxcapi_migrate(struct lxc_container *c, unsigned int cmd,
ret = -EINVAL;
}
on_error:
if (size < sizeof(*opts))
free(valid_opts);
......
......@@ -545,7 +545,7 @@ int ovl_mount(struct lxc_storage *bdev)
upper++;
/* if delta doesn't yet exist, create it */
ret = mkdir_p(upper, 0755) < 0;
ret = mkdir_p(upper, 0755);
if (ret < 0 && errno != EEXIST) {
SYSERROR("Failed to create directory \"%s\"", upper);
free(dup);
......
......@@ -80,6 +80,7 @@ int lxc_rsync_exec(const char *src, const char *dest)
s[l - 1] = '\0';
execlp("rsync", "rsync", "-aHXS", "--delete", s, dest, (char *)NULL);
free(s);
return -1;
}
......
......@@ -55,6 +55,10 @@ static void try_to_remove(void)
int main(int argc, char *argv[])
{
int i, n, ret;
char path[1024];
struct stat sb;
struct lxc_snapshot *s;
struct lxc_container *c, *c2 = NULL;
char *template = "busybox";
......@@ -89,19 +93,18 @@ int main(int argc, char *argv[])
}
// rootfs should be ${lxcpath}${lxcname}/snaps/snap0/rootfs
struct stat sb;
int ret;
char path[1024];
snprintf(path, 1024, "%s/%s/snaps/snap0/rootfs", lxc_get_global_config_item("lxc.lxcpath"), MYNAME);
ret = snprintf(path, 1024, "%s/%s/snaps/snap0/rootfs", lxc_get_global_config_item("lxc.lxcpath"), MYNAME);
if (ret < 0 || (size_t)ret >= 1024) {
fprintf(stderr, "%s: %d: failed to create string\n", __FILE__, __LINE__);
goto err;
}
ret = stat(path, &sb);
if (ret != 0) {
fprintf(stderr, "%s: %d: snapshot was not actually created\n", __FILE__, __LINE__);
goto err;
}
struct lxc_snapshot *s;
int i, n;
n = c->snapshot_list(c, &s);
if (n < 1) {
fprintf(stderr, "%s: %d: failed listing containers\n", __FILE__, __LINE__);
......
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