Skip to content

Commit

Permalink
Merge pull request containers#8030 from Luap99/fix-restore-panic
Browse files Browse the repository at this point in the history
Fix possible panic in libpod container restore
  • Loading branch information
openshift-merge-robot authored Oct 15, 2020
2 parents a1d5a51 + 2e65497 commit a82d60d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions libpod/container_internal_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1024,13 +1024,15 @@ func (c *Container) restore(ctx context.Context, options ContainerCheckpointOpti
if !options.IgnoreStaticMAC {
// Take the first device with a defined sandbox.
var MAC net.HardwareAddr
for _, n := range networkStatus[0].Interfaces {
if n.Sandbox != "" {
MAC, err = net.ParseMAC(n.Mac)
if err != nil {
return errors.Wrapf(err, "failed to parse MAC %v", n.Mac)
if len(networkStatus) > 0 {
for _, n := range networkStatus[0].Interfaces {
if n.Sandbox != "" {
MAC, err = net.ParseMAC(n.Mac)
if err != nil {
return errors.Wrapf(err, "failed to parse MAC %v", n.Mac)
}
break
}
break
}
}
if MAC != nil {
Expand Down

0 comments on commit a82d60d

Please sign in to comment.