rootfs: remove ./ prefix from filenames

I've seen a container (private one) whose filenames start with ./, but
the layer name does not have the prefix, causing undocker to fail.

Let's always normalize the names to not have the prefix.
This commit is contained in:
Motiejus Jakštys 2022-06-09 14:22:19 +03:00
parent 41baf180a3
commit 4408a9e005

View File

@ -69,7 +69,7 @@ func Flatten(rd io.ReadSeeker, w io.Writer) (_err error) {
if err != nil {
return err
}
layerOffsets[hdr.Name] = here
layerOffsets[strings.TrimPrefix(hdr.Name, "./")] = here
}
}
@ -82,7 +82,7 @@ func Flatten(rd io.ReadSeeker, w io.Writer) (_err error) {
for i, name := range manifest[0].Layers {
layers[i] = nameOffset{
name: name,
offset: layerOffsets[name],
offset: layerOffsets[strings.TrimPrefix(name, "./")],
}
}