Skip to content

Commit

Permalink
Clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley committed May 9, 2024
1 parent 902e5f8 commit 32cd885
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 4 deletions.
16 changes: 15 additions & 1 deletion sdk/checksum/checksum.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ package checksum
import (
"crypto/sha256"
"fmt"
"math"

log "github.com/sirupsen/logrus"
)

// Checksum - calculate checksum from []byte
Expand All @@ -36,8 +39,19 @@ func Chunk(buf []byte, lim int) [][]byte {
return [][]byte{buf}
}

chunks := make([][]byte, 0)
if lim <= 0 {
log.Error("Unable to chuck payload, chunk size is too small")
return [][]byte{}
}

chuckSize := bufSize / lim

if chuckSize > math.MaxInt64-1 {
log.Error("Unable to chuck payload, data too large")
return [][]byte{}
}

chunks := make([][]byte, 0, chuckSize+1)

Check failure

Code scanning / CodeQL

Size computation for allocation may overflow High

This operation, which is used in an
allocation
, involves a
potentially large value
and might overflow.
This operation, which is used in an
allocation
, involves a
potentially large value
and might overflow.
for len(buf) >= lim {
chunk, buf = buf[:lim], buf[lim:]
chunks = append(chunks, chunk)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 15 additions & 1 deletion vendor/github.com/nginx/agent/sdk/v2/checksum/checksum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 32cd885

Please sign in to comment.