From 53834ef0dcb7cbf889232a2d9c1c5dceb83908f5 Mon Sep 17 00:00:00 2001 From: xtexChooser Date: Sun, 11 Jun 2023 08:50:04 +0800 Subject: [PATCH 1/2] fix(specgen): index out of range when unmask=[] Fixes #18848 Signed-off-by: xtexChooser --- pkg/specgen/generate/oci_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/specgen/generate/oci_linux.go b/pkg/specgen/generate/oci_linux.go index 2a1afbecc4..233b6c1eaf 100644 --- a/pkg/specgen/generate/oci_linux.go +++ b/pkg/specgen/generate/oci_linux.go @@ -57,7 +57,7 @@ func getCgroupPermissions(unmask []string) string { return ro } - if unmask != nil && unmask[0] == "ALL" { + if unmask != nil && len(unmask) != 0 && unmask[0] == "ALL" { return rw } From d734fcbff24ddb2663b50b8dd8ea3e0150bc91e3 Mon Sep 17 00:00:00 2001 From: xtexChooser Date: Sun, 11 Jun 2023 09:39:15 +0800 Subject: [PATCH 2/2] style(specgen): omit nil check len(nil) == 0 [NO NEW TESTS NEEDED] Signed-off-by: xtex --- pkg/specgen/generate/oci_linux.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/specgen/generate/oci_linux.go b/pkg/specgen/generate/oci_linux.go index 233b6c1eaf..ddba5f7175 100644 --- a/pkg/specgen/generate/oci_linux.go +++ b/pkg/specgen/generate/oci_linux.go @@ -57,7 +57,7 @@ func getCgroupPermissions(unmask []string) string { return ro } - if unmask != nil && len(unmask) != 0 && unmask[0] == "ALL" { + if len(unmask) != 0 && unmask[0] == "ALL" { return rw }