aboutsummaryrefslogtreecommitdiffstats
path: root/common/hexutil/hexutil.go
diff options
context:
space:
mode:
authorFelix Lange <fjl@twurst.com>2017-02-23 00:55:04 +0800
committerFelix Lange <fjl@twurst.com>2017-03-02 21:05:46 +0800
commit357d00cdb1625e4a715e0b3928ef7bd3656a8d95 (patch)
tree4518eaeeaab9381d64c92aa8794882d313f72aad /common/hexutil/hexutil.go
parentf3b7dcc5bdd5b2b02e12133a0d8e16a75844f766 (diff)
downloadgo-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar.gz
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar.bz2
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar.lz
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar.xz
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.tar.zst
go-tangerine-357d00cdb1625e4a715e0b3928ef7bd3656a8d95.zip
common/hexutil: don't leak encoding/hex errors in Decode
All other functions return errors from package hexutil, ensure that Decode does too.
Diffstat (limited to 'common/hexutil/hexutil.go')
-rw-r--r--common/hexutil/hexutil.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/common/hexutil/hexutil.go b/common/hexutil/hexutil.go
index 16863f6c0..b66c0d3fe 100644
--- a/common/hexutil/hexutil.go
+++ b/common/hexutil/hexutil.go
@@ -60,7 +60,11 @@ func Decode(input string) ([]byte, error) {
if !has0xPrefix(input) {
return nil, ErrMissingPrefix
}
- return hex.DecodeString(input[2:])
+ b, err := hex.DecodeString(input[2:])
+ if err != nil {
+ err = mapError(err)
+ }
+ return b, err
}
// MustDecode decodes a hex string with 0x prefix. It panics for invalid input.