mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
Potential fix for code scanning alert no. 5: Size computation for allocation may overflow
Romeo Rosete Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
This commit is contained in:
parent
8a2555885d
commit
a1b9e741d4
1 changed files with 3 additions and 0 deletions
|
|
@ -82,6 +82,9 @@ func MustDecode(input string) []byte {
|
||||||
|
|
||||||
// Encode encodes b as a hex string with 0x prefix.
|
// Encode encodes b as a hex string with 0x prefix.
|
||||||
func Encode(b []byte) string {
|
func Encode(b []byte) string {
|
||||||
|
if len(b) > (int(^uint(0) >> 1))/2 {
|
||||||
|
panic("input too large to encode as hex string")
|
||||||
|
}
|
||||||
enc := make([]byte, len(b)*2+2)
|
enc := make([]byte, len(b)*2+2)
|
||||||
copy(enc, "0x")
|
copy(enc, "0x")
|
||||||
hex.Encode(enc[2:], b)
|
hex.Encode(enc[2:], b)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue