Skip to content

Commit

Permalink
Fix code scanning alert no. 8760: Size computation for allocation may…
Browse files Browse the repository at this point in the history
… overflow

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Signed-off-by: Yusuke Kato <[email protected]>
  • Loading branch information
kpango and github-advanced-security[bot] authored Dec 9, 2024
1 parent 48a71cd commit 00bf13b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion hack/docker/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,12 @@ jobs:
// remove the double quotation marks from the generated key "on": (note that the word "on" is a reserved word in sigs.k8s.io/yaml)
workflowYaml := strings.Replace(string(workflowYamlTmp), "\"on\":", "on:", 1)

buf := bytes.NewBuffer(make([]byte, 0, len(header)+len(workflowYaml)))
totalLen := len(header) + len(workflowYaml)

Check failure

Code scanning / CodeQL

Size computation for allocation may overflow High generated

This operation, which is used in an
allocation
, involves a
potentially large value
and might overflow.
if totalLen < len(header) || totalLen < len(workflowYaml) {
return fmt.Errorf("size computation for allocation may overflow")
}

buf := bytes.NewBuffer(make([]byte, 0, totalLen))
err = license.Execute(buf, data)
if err != nil {
return fmt.Errorf("error executing template: %w", err)
Expand Down

0 comments on commit 00bf13b

Please sign in to comment.