Unverified Commit e0d498f1 by Jonathan Calmels Committed by Christian Brauner

overlay: fix out-of-bounds copy

parent 6fd10c62
...@@ -410,15 +410,12 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n, ...@@ -410,15 +410,12 @@ int ovl_create(struct lxc_storage *bdev, const char *dest, const char *n,
return -1; return -1;
} }
delta = malloc(len + 1); delta = strdup(dest);
if (!delta) { if (!delta) {
ERROR("Failed to allocate memory"); ERROR("Failed to allocate memory");
return -1; return -1;
} }
memcpy(delta, dest, len);
memcpy(delta + len - 6, "delta0", sizeof("delta0") - 1); memcpy(delta + len - 6, "delta0", sizeof("delta0") - 1);
delta[len + sizeof("delta0")] = '\0';
ret = mkdir_p(delta, 0755); ret = mkdir_p(delta, 0755);
if (ret < 0) { if (ret < 0) {
......
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