Skip to content

Commit

Permalink
dev: chg: fix size allocation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
marcello33 committed Oct 10, 2023
1 parent a50c10d commit b7a471c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
3 changes: 1 addition & 2 deletions accounts/usbwallet/trezor.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"errors"
"fmt"
"io"
"math"
"math/big"

"github.com/ethereum/go-ethereum/accounts"
Expand Down Expand Up @@ -309,7 +308,7 @@ func (w *trezorDriver) trezorExchange(req proto.Message, results ...proto.Messag

var payload []byte

if 8+len(data) < math.MaxInt {
if 8+len(data) < 64*1024*1024 {
payload = make([]byte, 8+len(data))

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.
}

Expand Down
3 changes: 1 addition & 2 deletions core/vm/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package vm

import (
"math"
"math/big"

"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -147,7 +146,7 @@ func (c *Contract) AsDelegate() *Contract {

// GetOp returns the n'th element in the contract's byte array
func (c *Contract) GetOp(n uint64) OpCode {
if len(c.Code) > 0 && len(c.Code) <= math.MaxUint16 && n < uint64(len(c.Code)) {
if len(c.Code) > 0 && len(c.Code) <= 64*1024*1024 && n < uint64(len(c.Code)) {
return OpCode(c.Code[n])

Check failure

Code scanning / CodeQL

Incorrect conversion between integer types High

Incorrect conversion of a 64-bit integer from
strconv.ParseUint
to a lower bit size type uint8 without an upper bound check.
}

Expand Down

0 comments on commit b7a471c

Please sign in to comment.