Merge pull request #8030 from Luap99/fix-restore-panic

Fix possible panic in libpod container restore
This commit is contained in:
OpenShift Merge Robot 2020-10-15 10:09:40 -04:00 committed by GitHub
commit a82d60db0f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 6 deletions

View File

@ -1024,13 +1024,15 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
if !options.IgnoreStaticMAC { if !options.IgnoreStaticMAC {
// Take the first device with a defined sandbox. // Take the first device with a defined sandbox.
var MAC net.HardwareAddr var MAC net.HardwareAddr
for _, n := range networkStatus[0].Interfaces { if len(networkStatus) > 0 {
if n.Sandbox != "" { for _, n := range networkStatus[0].Interfaces {
MAC, err = net.ParseMAC(n.Mac) if n.Sandbox != "" {
if err != nil { MAC, err = net.ParseMAC(n.Mac)
return errors.Wrapf(err, "failed to parse MAC %v", n.Mac) if err != nil {
return errors.Wrapf(err, "failed to parse MAC %v", n.Mac)
}
break
} }
break
} }
} }
if MAC != nil { if MAC != nil {