The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/go-lxc/pull/142
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Avoids crashes by passing nil container to liblxc if it has been freed.
From 70331db540ebc4a30247e6d8e4ef2c6330375f18 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Wed, 26 Aug 2020 15:51:00 +0100 Subject: [PATCH 1/2] container: Check c.container isn't nil to protect against crash Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- container.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/container.go b/container.go index eb8a415..8c8da83 100644 --- a/container.go +++ b/container.go @@ -279,6 +279,10 @@ func (c *Container) Snapshots() ([]Snapshot, error) { // Caller needs to hold the lock func (c *Container) state() State { + if c.container == nil { + return StateMap["STOPPED"] + } + return StateMap[C.GoString(C.go_lxc_state(c.container))] } From 762f161f646758e7d61a85a0f23ad5faa8840664 Mon Sep 17 00:00:00 2001 From: Thomas Parrott <thomas.parr...@canonical.com> Date: Wed, 26 Aug 2020 15:51:19 +0100 Subject: [PATCH 2/2] container: golint Signed-off-by: Thomas Parrott <thomas.parr...@canonical.com> --- container.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/container.go b/container.go index 8c8da83..7a9c5d5 100644 --- a/container.go +++ b/container.go @@ -1991,20 +1991,20 @@ func buildBdevSpecs(o *BackendStoreSpecs) *C.struct_bdev_specs { if o.FSType != "" { fstype := C.CString(o.FSType) - specs.fstype = fstype + specs.fstype = fstype defer C.free(unsafe.Pointer(fstype)) } - if o.FSSize > 0 { + if o.FSSize > 0 { specs.fssize = C.uint64_t(o.FSSize) } - if o.ZFS.Root != "" { + if o.ZFS.Root != "" { zfsroot := C.CString(o.ZFS.Root) specs.zfs.zfsroot = zfsroot defer C.free(unsafe.Pointer(zfsroot)) } - + if o.LVM.VG != "" { vg := C.CString(o.LVM.VG) specs.lvm.vg = vg
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel