summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGiuseppe Scrivano <gscrivan@redhat.com>2019-09-30 09:32:03 +0200
committerGiuseppe Scrivano <gscrivan@redhat.com>2019-10-01 08:51:57 +0200
commit9faa6456da8f1a0bb647148802f89d498348a570 (patch)
tree6bfb95b0f39ed50a5ee703fa59fee5397044706b
parentd7eba026876e4a6a362464dcf08fe6757ebedd1a (diff)
downloadpodman-9faa6456da8f1a0bb647148802f89d498348a570.tar.gz
podman-9faa6456da8f1a0bb647148802f89d498348a570.tar.bz2
podman-9faa6456da8f1a0bb647148802f89d498348a570.zip
networking: fix segfault when slirp4netns is missing
fixes a segfault when slirp4netns is not installed and the slirp sync pipe is not created. Closes: https://github.com/containers/libpod/issues/4113 Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
-rw-r--r--libpod/oci_internal_linux.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/libpod/oci_internal_linux.go b/libpod/oci_internal_linux.go
index a5cce795b..437b7cf4d 100644
--- a/libpod/oci_internal_linux.go
+++ b/libpod/oci_internal_linux.go
@@ -137,8 +137,12 @@ func (r *OCIRuntime) createOCIContainer(ctr *Container, restoreOptions *Containe
return errors.Wrapf(err, "failed to create rootless network sync pipe")
}
} else {
- defer errorhandling.CloseQuiet(ctr.rootlessSlirpSyncR)
- defer errorhandling.CloseQuiet(ctr.rootlessSlirpSyncW)
+ if ctr.rootlessSlirpSyncR != nil {
+ defer errorhandling.CloseQuiet(ctr.rootlessSlirpSyncR)
+ }
+ if ctr.rootlessSlirpSyncW != nil {
+ defer errorhandling.CloseQuiet(ctr.rootlessSlirpSyncW)
+ }
}
// Leak one end in conmon, the other one will be leaked into slirp4netns
cmd.ExtraFiles = append(cmd.ExtraFiles, ctr.rootlessSlirpSyncW)