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: Christian Brauner <christian.brau...@mailbox.org> --- src/lxc/bdev/lxcoverlay.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/lxc/bdev/lxcoverlay.c b/src/lxc/bdev/lxcoverlay.c index d06d24f..5ffc289 100644 --- a/src/lxc/bdev/lxcoverlay.c +++ b/src/lxc/bdev/lxcoverlay.c @@ -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++; -- 2.7.0 _______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel