Files
codeql/go/ql/test/query-tests/Security/CWE-190/AllocationSizeOverflow.go
2022-05-20 10:07:19 -07:00

15 lines
293 B
Go

package main
import "encoding/json"
func encryptValue(v interface{}) ([]byte, error) {
jsonData, err := json.Marshal(v)
if err != nil {
return nil, err
}
size := len(jsonData) + (len(jsonData) % 16)
buffer := make([]byte, size)
copy(buffer, jsonData)
return encryptBuffer(buffer)
}