mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-26 06:36:43 +00:00
fixes
This commit is contained in:
parent
15d42486c6
commit
750a07e5d4
2 changed files with 11 additions and 0 deletions
|
|
@ -512,6 +512,12 @@ func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHas
|
||||||
// APDU length | 1 byte
|
// APDU length | 1 byte
|
||||||
// Optional APDU data | arbitrary
|
// Optional APDU data | arbitrary
|
||||||
func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) {
|
func (w *ledgerDriver) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 ledgerParam2, data []byte) ([]byte, error) {
|
||||||
|
// max safe length check
|
||||||
|
const maxDataLength = 128 * 1024 * 1024 // 128 MB
|
||||||
|
if len(data) > maxDataLength {
|
||||||
|
return nil, errors.New("data too large")
|
||||||
|
}
|
||||||
|
|
||||||
// Construct the message payload, possibly split into multiple chunks
|
// Construct the message payload, possibly split into multiple chunks
|
||||||
apdu := make([]byte, 2, 7+len(data))
|
apdu := make([]byte, 2, 7+len(data))
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@
|
||||||
|
|
||||||
package trie
|
package trie
|
||||||
|
|
||||||
|
import "math"
|
||||||
|
|
||||||
// Trie keys are dealt with in three distinct encodings:
|
// Trie keys are dealt with in three distinct encodings:
|
||||||
//
|
//
|
||||||
// KEYBYTES encoding contains the actual key and nothing else. This encoding is the
|
// KEYBYTES encoding contains the actual key and nothing else. This encoding is the
|
||||||
|
|
@ -104,6 +106,9 @@ func compactToHex(compact []byte) []byte {
|
||||||
}
|
}
|
||||||
|
|
||||||
func keybytesToHex(str []byte) []byte {
|
func keybytesToHex(str []byte) []byte {
|
||||||
|
if len(str) > math.MaxInt/2 {
|
||||||
|
panic("input too large")
|
||||||
|
}
|
||||||
l := len(str)*2 + 1
|
l := len(str)*2 + 1
|
||||||
|
|
||||||
var nibbles = make([]byte, l)
|
var nibbles = make([]byte, l)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue