summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2020-10-15 10:09:40 -0400
committerGitHub <noreply@github.com>2020-10-15 10:09:40 -0400
commita82d60db0f36ef870eeb02385a85ffb7fcfeb56e (patch)
treebd75221d1677f411745fecb50a5dfca94ec10455
parenta1d5a518d3e9db785b7f15e07c679b9ae041ccae (diff)
parent2e65497deaf63cbb7a9521b49ac69bbe223970e4 (diff)
downloadpodman-a82d60db0f36ef870eeb02385a85ffb7fcfeb56e.tar.gz
podman-a82d60db0f36ef870eeb02385a85ffb7fcfeb56e.tar.bz2
podman-a82d60db0f36ef870eeb02385a85ffb7fcfeb56e.zip
Merge pull request #8030 from Luap99/fix-restore-panic
Fix possible panic in libpod container restore
-rw-r--r--libpod/container_internal_linux.go14
1 files changed, 8 insertions, 6 deletions
diff --git a/libpod/container_internal_linux.go b/libpod/container_internal_linux.go
index 105623810..eff390e46 100644
--- a/libpod/container_internal_linux.go
+++ b/libpod/container_internal_linux.go
@@ -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 {