This commit is contained in:
marcello33 2025-03-30 09:29:55 +02:00
parent 15d42486c6
commit 750a07e5d4
No known key found for this signature in database
GPG key ID: 06128777E3C36B16
2 changed files with 11 additions and 0 deletions

View file

@ -512,6 +512,12 @@ func (w *ledgerDriver) ledgerSignTypedMessage(derivationPath []uint32, domainHas
// APDU length | 1 byte
// Optional APDU data | arbitrary
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
apdu := make([]byte, 2, 7+len(data))

View file

@ -16,6 +16,8 @@
package trie
import "math"
// Trie keys are dealt with in three distinct encodings:
//
// 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 {
if len(str) > math.MaxInt/2 {
panic("input too large")
}
l := len(str)*2 + 1
var nibbles = make([]byte, l)