Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
61f2279b
Unverified
Commit
61f2279b
authored
Feb 02, 2018
by
Martin Holst Swende
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
abi: fix missing method on go 1.7/1.8
parent
bd6ed238
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
13 deletions
+23
-13
unpack.go
accounts/abi/unpack.go
+23
-13
No files found.
accounts/abi/unpack.go
View file @
61f2279b
...
@@ -184,22 +184,32 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
...
@@ -184,22 +184,32 @@ func toGoType(index int, t Type, output []byte) (interface{}, error) {
// interprets a 32 byte slice as an offset and then determines which indice to look to decode the type.
// interprets a 32 byte slice as an offset and then determines which indice to look to decode the type.
func
lengthPrefixPointsTo
(
index
int
,
output
[]
byte
)
(
start
int
,
length
int
,
err
error
)
{
func
lengthPrefixPointsTo
(
index
int
,
output
[]
byte
)
(
start
int
,
length
int
,
err
error
)
{
offsetBig
:=
big
.
NewInt
(
0
)
.
SetBytes
(
output
[
index
:
index
+
32
])
bigOffsetEnd
:=
big
.
NewInt
(
0
)
.
SetBytes
(
output
[
index
:
index
+
32
])
if
!
offsetBig
.
IsInt64
()
{
bigOffsetEnd
.
Add
(
bigOffsetEnd
,
common
.
Big32
)
return
0
,
0
,
fmt
.
Errorf
(
"abi offset larger than int64: %v"
,
offsetBig
)
outputLength
:=
big
.
NewInt
(
int64
(
len
(
output
)))
if
bigOffsetEnd
.
Cmp
(
outputLength
)
>
0
{
return
0
,
0
,
fmt
.
Errorf
(
"abi: cannot marshal in to go slice: offset %v would go over slice boundary (len=%v)"
,
bigOffsetEnd
,
outputLength
)
}
}
offset
:=
int
(
offsetBig
.
Int64
())
if
offset
+
32
>
len
(
output
)
{
if
bigOffsetEnd
.
BitLen
()
>
63
{
return
0
,
0
,
fmt
.
Errorf
(
"abi
: cannot marshal in to go slice: offset %d would go over slice boundary (len=%d)"
,
len
(
output
),
offset
+
32
)
return
0
,
0
,
fmt
.
Errorf
(
"abi
offset larger than int64: %v"
,
bigOffsetEnd
)
}
}
lengthBig
:=
big
.
NewInt
(
0
)
.
SetBytes
(
output
[
offset
:
offset
+
32
])
if
!
lengthBig
.
IsInt64
()
{
offsetEnd
:=
int
(
bigOffsetEnd
.
Uint64
())
return
0
,
0
,
fmt
.
Errorf
(
"abi length larger than int64: %v"
,
lengthBig
)
lengthBig
:=
big
.
NewInt
(
0
)
.
SetBytes
(
output
[
offsetEnd
-
32
:
offsetEnd
])
totalSize
:=
big
.
NewInt
(
0
)
totalSize
.
Add
(
totalSize
,
bigOffsetEnd
)
totalSize
.
Add
(
totalSize
,
lengthBig
)
if
totalSize
.
BitLen
()
>
63
{
return
0
,
0
,
fmt
.
Errorf
(
"abi length larger than int64: %v"
,
totalSize
)
}
}
length
=
int
(
lengthBig
.
Int64
())
if
offset
+
32
+
length
>
len
(
output
)
{
if
totalSize
.
Cmp
(
outputLength
)
>
0
{
return
0
,
0
,
fmt
.
Errorf
(
"abi: cannot marshal in to go type: length insufficient %
d require %d"
,
len
(
output
),
offset
+
32
+
length
)
return
0
,
0
,
fmt
.
Errorf
(
"abi: cannot marshal in to go type: length insufficient %
v require %v"
,
outputLength
,
totalSize
)
}
}
start
=
offset
+
32
start
=
int
(
bigOffsetEnd
.
Uint64
())
length
=
int
(
lengthBig
.
Uint64
())
return
return
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment