archive: prevent breakout in Untar
Signed-off-by: Tibor Vass <teabee89@gmail.com>
This commit is contained in:
parent
1752a203af
commit
aa62eca940
2 changed files with 24 additions and 2 deletions
|
@ -10,6 +10,8 @@ import (
|
|||
|
||||
const maxLoopCounter = 100
|
||||
|
||||
type ErrBreakout error
|
||||
|
||||
// FollowSymlink will follow an existing link and scope it to the root
|
||||
// path provided.
|
||||
// The role of this function is to return an absolute path in the root
|
||||
|
@ -34,7 +36,7 @@ func FollowSymlinkInScope(link, root string) (string, error) {
|
|||
}
|
||||
|
||||
if !strings.HasPrefix(filepath.Dir(link), root) {
|
||||
return "", fmt.Errorf("%s is not within %s", link, root)
|
||||
return "", ErrBreakout(fmt.Errorf("%s is not within %s", link, root))
|
||||
}
|
||||
|
||||
prev := "/"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue