mirror of
https://github.com/anchore/syft.git
synced 2025-11-17 16:33:21 +01:00
fix: do not double-prefix symlink paths that already contain volume names (#2051)
Signed-off-by: Joseph Palermo <jpalermo@vmware.com> Signed-off-by: Chris Selzo <cselzo@vmware.com> Co-authored-by: Joseph Palermo <jpalermo@vmware.com>
This commit is contained in:
parent
1848aa22cf
commit
5ceef48949
@ -349,9 +349,13 @@ func (r directoryIndexer) addSymlinkToIndex(p string, info os.FileInfo) (string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if filepath.IsAbs(linkTarget) {
|
if filepath.IsAbs(linkTarget) {
|
||||||
|
linkTarget = filepath.Clean(linkTarget)
|
||||||
// if the link is absolute (e.g, /bin/ls -> /bin/busybox) we need to
|
// if the link is absolute (e.g, /bin/ls -> /bin/busybox) we need to
|
||||||
// resolve relative to the root of the base directory
|
// resolve relative to the root of the base directory, if it is not already
|
||||||
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget))
|
// prefixed with a volume name
|
||||||
|
if filepath.VolumeName(linkTarget) == "" {
|
||||||
|
linkTarget = filepath.Join(r.base, filepath.Clean(linkTarget))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// if the link is not absolute (e.g, /dev/stderr -> fd/2 ) we need to
|
// if the link is not absolute (e.g, /dev/stderr -> fd/2 ) we need to
|
||||||
// resolve it relative to the directory in question (e.g. resolve to
|
// resolve it relative to the directory in question (e.g. resolve to
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user