Fix possible panic in libpod container restore
We need to do a length check before we can access the
networkStatus slice by index to prevent a runtime panic.
Fixes
@@ -1024,6 +1024,7 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
if !options.IgnoreStaticMAC {
// Take the first device with a defined sandbox.
var MAC net.HardwareAddr
+ if len(networkStatus) > 0 {
for _, n := range networkStatus[0].Interfaces {
if n.Sandbox != "" {
MAC, err = net.ParseMAC(n.Mac)
@@ -1033,6 +1034,7 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
break
}
}
+ }
if MAC != nil {
// Tell CNI which MAC address we want.
c.requestedMAC = MAC
