Fixes 5370 infinite/maxLoopCount loop for relative symlinks

use path.IsAbs() instead of checking if first char is '/'

Docker-DCO-1.1-Signed-off-by: Lajos Papp <lajos.papp@sequenceiq.com> (github: lalyos)
This commit is contained in:
lalyos 2014-04-25 05:54:20 +02:00
parent 02b08b3961
commit 0b1aab5435

View file

@ -63,10 +63,9 @@ func FollowSymlinkInScope(link, root string) (string, error) {
return "", err return "", err
} }
switch dest[0] { if path.IsAbs(dest) {
case '/':
prev = filepath.Join(root, dest) prev = filepath.Join(root, dest)
case '.': } else {
prev, _ = filepath.Abs(prev) prev, _ = filepath.Abs(prev)
if prev = filepath.Clean(filepath.Join(filepath.Dir(prev), dest)); len(prev) < len(root) { if prev = filepath.Clean(filepath.Join(filepath.Dir(prev), dest)); len(prev) < len(root) {