summaryrefslogtreecommitdiff
path: root/pkg/util/utils.go
diff options
context:
space:
mode:
authorxatier <xatierlike@gmail.com>2021-08-13 02:49:57 -0500
committerxatier <xatierlike@gmail.com>2021-08-13 15:24:06 -0500
commitd9975643428c63f5402c0ac253e8c324a14ba15e (patch)
treeb979521502f690e2dc38741d06a818da955bb366 /pkg/util/utils.go
parent94886d4abad7787cb920614ed26955ca36b13846 (diff)
downloadpodman-d9975643428c63f5402c0ac253e8c324a14ba15e.tar.gz
podman-d9975643428c63f5402c0ac253e8c324a14ba15e.tar.bz2
podman-d9975643428c63f5402c0ac253e8c324a14ba15e.zip
Add space trimming check in ValidateSysctls
This is to catch invalid sysctl configs with extra spacing. See https://github.com/containers/common/issues/723#issuecomment-897395506 Signed-off-by: xatier <xatierlike@gmail.com>
Diffstat (limited to 'pkg/util/utils.go')
-rw-r--r--pkg/util/utils.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/pkg/util/utils.go b/pkg/util/utils.go
index 774590f44..63fad0286 100644
--- a/pkg/util/utils.go
+++ b/pkg/util/utils.go
@@ -618,6 +618,12 @@ func ValidateSysctls(strSlice []string) (map[string]string, error) {
if len(arr) < 2 {
return nil, errors.Errorf("%s is invalid, sysctl values must be in the form of KEY=VALUE", val)
}
+
+ trimmed := fmt.Sprintf("%s=%s", strings.TrimSpace(arr[0]), strings.TrimSpace(arr[1]))
+ if trimmed != val {
+ return nil, errors.Errorf("'%s' is invalid, extra spaces found", val)
+ }
+
if validSysctlMap[arr[0]] {
sysctl[arr[0]] = arr[1]
continue