aboutsummaryrefslogtreecommitdiffstats
path: root/accounts/abi/abi.go
diff options
context:
space:
mode:
authorBob Glickstein <bobg@users.noreply.github.com>2017-12-21 17:59:14 +0800
committerFelix Lange <fjl@users.noreply.github.com>2017-12-21 17:59:14 +0800
commite21aa0fda3b9d0b101d60d03e98a0bdd4d415dea (patch)
tree192aa0dde579e1f49497363fffb717dd18648b2f /accounts/abi/abi.go
parent9f1007e554e223b12354d3c91ae7fb040cf8b865 (diff)
downloadgo-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar.gz
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar.bz2
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar.lz
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar.xz
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.tar.zst
go-tangerine-e21aa0fda3b9d0b101d60d03e98a0bdd4d415dea.zip
accounts/abi: remove check for len%32==0 when unpacking events (#15670)
This change inlines the logic of bytesAreProper at its sole callsite, ABI.Unpack, and applies the multiple-of-32 test only in the case of unpacking methods. Event data is not required to be a multiple of 32 bytes long.
Diffstat (limited to 'accounts/abi/abi.go')
-rw-r--r--accounts/abi/abi.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/accounts/abi/abi.go b/accounts/abi/abi.go
index 205dc300b..02b4fa472 100644
--- a/accounts/abi/abi.go
+++ b/accounts/abi/abi.go
@@ -74,13 +74,17 @@ func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error) {
// Unpack output in v according to the abi specification
func (abi ABI) Unpack(v interface{}, name string, output []byte) (err error) {
- if err = bytesAreProper(output); err != nil {
- return err
+ if len(output) == 0 {
+ return fmt.Errorf("abi: unmarshalling empty output")
}
+
// since there can't be naming collisions with contracts and events,
// we need to decide whether we're calling a method or an event
var unpack unpacker
if method, ok := abi.Methods[name]; ok {
+ if len(output)%32 != 0 {
+ return fmt.Errorf("abi: improperly formatted output")
+ }
unpack = method
} else if event, ok := abi.Events[name]; ok {
unpack = event