Skip to content

Commit

Permalink
BUG/MEDIUM: raw: sanitizer incorectly wrote config as a pointer addr
Browse files Browse the repository at this point in the history
  • Loading branch information
mjuraga committed Sep 26, 2024
1 parent f9dffa6 commit 29b9d34
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions configuration/raw.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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
Expand All @@ -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 {
Expand Down

0 comments on commit 29b9d34

Please sign in to comment.