[lxc-devel] [go-lxc/v2] Fixes crash in cgroupItem()

tomponline on Github lxc-bot at linuxcontainers.org
Mon Oct 12 11:11:08 UTC 2020


A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 27422 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20201012/d1145b47/attachment-0001.bin>
-------------- next part --------------
From 5dd5308fffcf4c9713bdf392fefe68bbaca1157f Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 12 Oct 2020 12:09:50 +0100
Subject: [PATCH 1/2] container: Fixes crash in cgroupItem()

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 container.go | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/container.go b/container.go
index 7a9c5d5..caa2d72 100644
--- a/container.go
+++ b/container.go
@@ -838,6 +838,10 @@ func (c *Container) RunningConfigItem(key string) []string {
 }
 
 func (c *Container) cgroupItem(key string) []string {
+	if c.container == nil {
+		return nil
+	}
+
 	ckey := C.CString(key)
 	defer C.free(unsafe.Pointer(ckey))
 

From 9e65e12275c754b980fc5d81da0771d1b04b0e28 Mon Sep 17 00:00:00 2001
From: Thomas Parrott <thomas.parrott at canonical.com>
Date: Mon, 12 Oct 2020 12:10:02 +0100
Subject: [PATCH 2/2] options: go fmt

Signed-off-by: Thomas Parrott <thomas.parrott at canonical.com>
---
 options.go | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/options.go b/options.go
index 060abd5..08a64eb 100644
--- a/options.go
+++ b/options.go
@@ -107,12 +107,11 @@ type TemplateOptions struct {
 	ExtraArgs []string
 }
 
-
 type BackendStoreSpecs struct {
 	FSType string
 	FSSize uint64
-	Dir *string
-	ZFS struct {
+	Dir    *string
+	ZFS    struct {
 		Root string
 	}
 	LVM struct {
@@ -123,7 +122,6 @@ type BackendStoreSpecs struct {
 	}
 }
 
-
 // DownloadTemplateOptions is a convenient set of options for "download" template.
 var DownloadTemplateOptions = TemplateOptions{
 	Template: "download",


More information about the lxc-devel mailing list