Skip to content

Commit

Permalink
Fix code scanning alert no. 8914: 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 00bf13b commit 8bb0c2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hack/docker/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -1023,10 +1023,10 @@ 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)

totalLen := len(header) + len(workflowYaml)
if totalLen < len(header) || totalLen < len(workflowYaml) {
if len(header) > (int(^uint(0) >> 1) - len(workflowYaml)) {
return fmt.Errorf("size computation for allocation may overflow")
}
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.

buf := bytes.NewBuffer(make([]byte, 0, totalLen))
err = license.Execute(buf, data)
Expand Down

0 comments on commit 8bb0c2f

Please sign in to comment.