From 7cb9574c8aa785d8b14fe4182fbe4bda74e5b1e8 Mon Sep 17 00:00:00 2001 From: Marko Juraga Date: Thu, 26 Sep 2024 16:38:00 +0200 Subject: [PATCH] BUG/MEDIUM: raw: sanitizer incorectly wrote config as a pointer addr --- configuration/raw.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/configuration/raw.go b/configuration/raw.go index e89d7e49..5c7622b1 100644 --- a/configuration/raw.go +++ b/configuration/raw.go @@ -180,7 +180,7 @@ func (c *client) PostRawConfiguration(config *string, version int64, skipVersion w := bufio.NewWriter(tmp) if !skipVersionCheck { - _, _ = w.WriteString(fmt.Sprintf("# _version=%v\n%v", version, c.dropVersionFromRaw(*config))) + _, _ = w.WriteString(fmt.Sprintf("# _version=%d\n%s", version, c.dropVersionFromRaw(*config))) } else { _, _ = w.WriteString(*config) } @@ -206,7 +206,7 @@ func (c *client) PostRawConfiguration(config *string, version int64, skipVersion // dropVersionFromRaw is used when force pushing a raw configuration with version check: // if the provided user input has already a version metadata it must be withdrawn. -func (c *client) dropVersionFromRaw(input string) *string { +func (c *client) dropVersionFromRaw(input string) string { scanner := bufio.NewScanner(strings.NewReader(input)) var sanitized strings.Builder @@ -222,9 +222,7 @@ func (c *client) dropVersionFromRaw(input string) *string { sanitized.WriteByte('\n') } - str := sanitized.String() - - return &str + return sanitized.String() } func (c *client) validateConfigFile(confFile string) error {