Commit 9208af16 by Christian Brauner Committed by Stéphane Graber

lxc.rootfs: support multiple lower layers

Do it in a safe way by using strstr() to check for the substring ":/" should ':' be part of a pathname. This should be a safer implementation than the one originally suggested in #547. Signed-off-by: 's avatarChristian Brauner <christian.brauner@mailbox.org> Acked-by: 's avatarSerge E. Hallyn <serge.hallyn@ubuntu.com>
parent f267d666
......@@ -309,7 +309,7 @@ char *ovl_getlower(char *p)
int ovl_mount(struct bdev *bdev)
{
char *options, *dup, *lower, *upper;
char *tmp, *options, *dup, *lower, *upper;
char *options_work, *work, *lastslash;
int lastslashidx;
int len, len2;
......@@ -331,9 +331,15 @@ int ovl_mount(struct bdev *bdev)
*/
dup = alloca(strlen(bdev->src) + 1);
strcpy(dup, bdev->src);
if (!(lower = strchr(dup, ':')))
return -22;
if (!(upper = strchr(++lower, ':')))
/* support multiple lower layers */
if (!(lower = strstr(dup, ":/")))
return -22;
lower++;
upper = lower;
while ((tmp = strstr(++upper, ":/"))) {
upper = tmp;
}
if (--upper == lower)
return -22;
*upper = '\0';
upper++;
......
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