Commit 41609c46 by Stéphane Graber Committed by GitHub

Merge pull request #1715 from brauner/2017-07-27/fix_gcc7_bug

lvm: check whether lxc.bdev.lvm.vg is empty
parents bef81ce5 bb30b52a
...@@ -307,6 +307,11 @@ int lvm_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname, ...@@ -307,6 +307,11 @@ int lvm_clonepaths(struct bdev *orig, struct bdev *new, const char *oldname,
return -1; return -1;
} }
vg = lxc_global_config_value("lxc.bdev.lvm.vg"); vg = lxc_global_config_value("lxc.bdev.lvm.vg");
if (!vg) {
ERROR("The \"lxc.bdev.lvm.vg\" key is not set");
return -1;
}
len = strlen("/dev/") + strlen(vg) + strlen(cname) + 4 + 2; len = strlen("/dev/") + strlen(vg) + strlen(cname) + 4 + 2;
new->src = malloc(len); new->src = malloc(len);
if (new->src) if (new->src)
......
...@@ -1315,7 +1315,7 @@ static inline bool cgfsng_create(void *hdata) ...@@ -1315,7 +1315,7 @@ static inline bool cgfsng_create(void *hdata)
{ {
struct cgfsng_handler_data *d = hdata; struct cgfsng_handler_data *d = hdata;
char *tmp, *cgname, *offset; char *tmp, *cgname, *offset;
int i, ret; int i;
int idx = 0; int idx = 0;
size_t len; size_t len;
...@@ -1343,6 +1343,8 @@ again: ...@@ -1343,6 +1343,8 @@ again:
goto out_free; goto out_free;
} }
if (idx) { if (idx) {
int ret;
ret = snprintf(offset, 5, "-%d", idx); ret = snprintf(offset, 5, "-%d", idx);
if (ret < 0 || (size_t)ret >= 5) { if (ret < 0 || (size_t)ret >= 5) {
FILE *f = fopen("/dev/null", "w"); FILE *f = fopen("/dev/null", "w");
......
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