2
0
mirror of git://github.com/lxc/lxc synced 2025-08-31 12:59:32 +00:00

overlay: fix use after free()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner
2017-09-10 07:04:34 +02:00
parent 7a643c7c02
commit e10e9f59ac

View File

@@ -201,9 +201,8 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
nsrc = strchr(osrc, ':') + 1; nsrc = strchr(osrc, ':') + 1;
if ((nsrc != osrc + 8) && (nsrc != osrc + 10)) { if ((nsrc != osrc + 8) && (nsrc != osrc + 10)) {
ERROR("Detected \":\" in \"%s\" at wrong position", osrc);
free(osrc); free(osrc);
ERROR("Detected \":\" in \"%s\" at wrong position",
osrc);
return -22; return -22;
} }
@@ -220,9 +219,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
ret = mkdir(ndelta, 0755); ret = mkdir(ndelta, 0755);
if (ret < 0 && errno != EEXIST) { if (ret < 0 && errno != EEXIST) {
SYSERROR("Failed to create directory \"%s\"", ndelta);
free(osrc); free(osrc);
free(ndelta); free(ndelta);
SYSERROR("Failed to create directory \"%s\"", ndelta);
return -1; return -1;
} }
@@ -238,9 +237,9 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
*/ */
lastslash = strrchr(ndelta, '/'); lastslash = strrchr(ndelta, '/');
if (!lastslash) { if (!lastslash) {
ERROR("Failed to detect \"/\" in \"%s\"", ndelta);
free(osrc); free(osrc);
free(ndelta); free(ndelta);
ERROR("Failed to detect \"/\" in \"%s\"", ndelta);
return -1; return -1;
} }
lastslash++; lastslash++;
@@ -260,10 +259,10 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
ret = mkdir(work, 0755); ret = mkdir(work, 0755);
if (ret < 0 && errno != EEXIST) { if (ret < 0 && errno != EEXIST) {
SYSERROR("Failed to create directory \"%s\"", ndelta);
free(osrc); free(osrc);
free(ndelta); free(ndelta);
free(work); free(work);
SYSERROR("Failed to create directory \"%s\"", ndelta);
return -1; return -1;
} }
@@ -323,7 +322,7 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
s1 = strrchr(clean_old_path, '/'); s1 = strrchr(clean_old_path, '/');
if (!s1) { if (!s1) {
ERROR("Failed to detect \"/\" in string \"%s\"", s1); ERROR("Failed to detect \"/\" in string \"%s\"", clean_old_path);
free(clean_old_path); free(clean_old_path);
free(clean_new_path); free(clean_new_path);
return -1; return -1;
@@ -331,7 +330,7 @@ int ovl_clonepaths(struct lxc_storage *orig, struct lxc_storage *new, const char
s2 = strrchr(clean_new_path, '/'); s2 = strrchr(clean_new_path, '/');
if (!s2) { if (!s2) {
ERROR("Failed to detect \"/\" in string \"%s\"", s2); ERROR("Failed to detect \"/\" in string \"%s\"", clean_new_path);
free(clean_old_path); free(clean_old_path);
free(clean_new_path); free(clean_new_path);
return -1; return -1;