Fix out-of-bounds panic in dedupMounts
It looks like the intent is to keep track of the index in 'ret' where a destination was written, but that's not what the current code is doing. Signed-off-by: Aaron Lehmann <alehmann@netflix.com>master
parent
bfd3cfb6a0
commit
9534552955
|
@ -104,11 +104,11 @@ func withBoundProc() oci.SpecOpts {
|
|||
func dedupMounts(mnts []specs.Mount) []specs.Mount {
|
||||
ret := make([]specs.Mount, 0, len(mnts))
|
||||
visited := make(map[string]int)
|
||||
for i, mnt := range mnts {
|
||||
for _, mnt := range mnts {
|
||||
if j, ok := visited[mnt.Destination]; ok {
|
||||
ret[j] = mnt
|
||||
} else {
|
||||
visited[mnt.Destination] = i
|
||||
visited[mnt.Destination] = len(ret)
|
||||
ret = append(ret, mnt)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue