mirror of
https://github.com/clearlinux/docker.git
synced 2026-10-03 23:38:24 +00:00
tarsum: name collision fix
If a tar were constructed with duplicate file names, then depending on the order, it could result in same tarsum. Signed-off-by: Vincent Batts <vbatts@redhat.com>
This commit is contained in:
@@ -214,11 +214,11 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp
|
||||
return err
|
||||
} else if fi.IsDir() {
|
||||
var subfiles []string
|
||||
for file, sum := range sums {
|
||||
absFile := path.Join(b.contextPath, file)
|
||||
for _, fileInfo := range sums {
|
||||
absFile := path.Join(b.contextPath, fileInfo.Name())
|
||||
absOrigPath := path.Join(b.contextPath, origPath)
|
||||
if strings.HasPrefix(absFile, absOrigPath) {
|
||||
subfiles = append(subfiles, sum)
|
||||
subfiles = append(subfiles, fileInfo.Sum())
|
||||
}
|
||||
}
|
||||
sort.Strings(subfiles)
|
||||
@@ -230,8 +230,9 @@ func (b *Builder) runContextCommand(args []string, allowRemote bool, allowDecomp
|
||||
origPath = origPath[1:]
|
||||
}
|
||||
origPath = strings.TrimPrefix(origPath, "./")
|
||||
if h, ok := sums[origPath]; ok {
|
||||
hash = "file:" + h
|
||||
// This will match on the first file in sums of the archive
|
||||
if fis := sums.GetFile(origPath); fis != nil {
|
||||
hash = "file:" + fis.Sum()
|
||||
}
|
||||
}
|
||||
b.Config.Cmd = []string{"/bin/sh", "-c", fmt.Sprintf("#(nop) %s %s in %s", cmdName, hash, dest)}
|
||||
|
||||
Reference in New Issue
Block a user