aboutsummaryrefslogtreecommitdiffstats
path: root/common/hexutil/hexutil.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-02-23 00:35:11 +0800
committerFelix Lange <fjl@twurst.com>2017-03-02 21:05:46 +0800
commitf3b7dcc5bdd5b2b02e12133a0d8e16a75844f766 (patch)
tree8ec56c1b7e2aa996184a8b8c5f1a1d9eefb4f92b /common/hexutil/hexutil.go
parentc52ab932e61ef9eba37c107e8b58b22c7d32e6c2 (diff)
downloaddexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar.gz
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar.bz2
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar.lz
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar.xz
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.tar.zst
dexon-f3b7dcc5bdd5b2b02e12133a0d8e16a75844f766.zip
common/hexutil: reject big integer inputs > 256 bits
This follows the change to common/math big integer parsing in PR #3699.
Diffstat (limited to 'common/hexutil/hexutil.go')
-rw-r--r--common/hexutil/hexutil.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go
index 4ec0ee8e6..16863f6c0 100644
--- a/common/hexutil/hexutil.go
+++ b/common/hexutil/hexutil.go
@@ -49,6 +49,7 @@ var (
ErrOddLength = errors.New("hex string has odd length")
ErrUint64Range = errors.New("hex number does not fit into 64 bits")
ErrUintRange = fmt.Errorf("hex number does not fit into %d bits", uintBits)
+ ErrBig256Range = errors.New("hex number does not fit into 256 bits")
)
// Decode decodes a hex string with 0x prefix.
@@ -126,11 +127,15 @@ func init() {
}
// DecodeBig decodes a hex string with 0x prefix as a quantity.
+// Numbers larger than 256 bits are not accepted.
func DecodeBig(input string) (*big.Int, error) {
raw, err := checkNumber(input)
if err != nil {
return nil, err
}
+ if len(raw) > 64 {
+ return nil, ErrBig256Range
+ }
words := make([]big.Word, len(raw)/bigWordNibbles+1)
end := len(raw)
for i := range words {