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
59597d23
Commit
59597d23
authored
Apr 04, 2015
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reject integers w/ appended zero's
parent
c39484bc
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
0 deletions
+10
-0
decode.go
rlp/decode.go
+9
-0
decode_test.go
rlp/decode_test.go
+1
-0
No files found.
rlp/decode.go
View file @
59597d23
...
@@ -99,6 +99,8 @@ func (err *decodeError) Error() string {
...
@@ -99,6 +99,8 @@ func (err *decodeError) Error() string {
func
wrapStreamError
(
err
error
,
typ
reflect
.
Type
)
error
{
func
wrapStreamError
(
err
error
,
typ
reflect
.
Type
)
error
{
switch
err
{
switch
err
{
case
ErrCanonInt
:
return
&
decodeError
{
msg
:
"canon int error appends zero's"
,
typ
:
typ
}
case
ErrExpectedList
:
case
ErrExpectedList
:
return
&
decodeError
{
msg
:
"expected input list"
,
typ
:
typ
}
return
&
decodeError
{
msg
:
"expected input list"
,
typ
:
typ
}
case
ErrExpectedString
:
case
ErrExpectedString
:
...
@@ -184,6 +186,12 @@ func decodeBigInt(s *Stream, val reflect.Value) error {
...
@@ -184,6 +186,12 @@ func decodeBigInt(s *Stream, val reflect.Value) error {
i
=
new
(
big
.
Int
)
i
=
new
(
big
.
Int
)
val
.
Set
(
reflect
.
ValueOf
(
i
))
val
.
Set
(
reflect
.
ValueOf
(
i
))
}
}
// Reject big integers which are zero appended
if
len
(
b
)
>
0
&&
b
[
0
]
==
0
{
return
wrapStreamError
(
ErrCanonInt
,
val
.
Type
())
}
i
.
SetBytes
(
b
)
i
.
SetBytes
(
b
)
return
nil
return
nil
}
}
...
@@ -460,6 +468,7 @@ var (
...
@@ -460,6 +468,7 @@ var (
// Other errors
// Other errors
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
ErrExpectedString
=
errors
.
New
(
"rlp: expected String or Byte"
)
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
ErrExpectedList
=
errors
.
New
(
"rlp: expected List"
)
ErrCanonInt
=
errors
.
New
(
"rlp: expected Int"
)
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
// internal errors
// internal errors
...
...
rlp/decode_test.go
View file @
59597d23
...
@@ -312,6 +312,7 @@ var decodeTests = []decodeTest{
...
@@ -312,6 +312,7 @@ var decodeTests = []decodeTest{
// big ints
// big ints
{
input
:
"01"
,
ptr
:
new
(
*
big
.
Int
),
value
:
big
.
NewInt
(
1
)},
{
input
:
"01"
,
ptr
:
new
(
*
big
.
Int
),
value
:
big
.
NewInt
(
1
)},
{
input
:
"89FFFFFFFFFFFFFFFFFF"
,
ptr
:
new
(
*
big
.
Int
),
value
:
veryBigInt
},
{
input
:
"89FFFFFFFFFFFFFFFFFF"
,
ptr
:
new
(
*
big
.
Int
),
value
:
veryBigInt
},
{
input
:
"820001"
,
ptr
:
new
(
big
.
Int
),
error
:
"rlp: canon int error appends zero's for *big.Int"
},
{
input
:
"10"
,
ptr
:
new
(
big
.
Int
),
value
:
*
big
.
NewInt
(
16
)},
// non-pointer also works
{
input
:
"10"
,
ptr
:
new
(
big
.
Int
),
value
:
*
big
.
NewInt
(
16
)},
// non-pointer also works
{
input
:
"C0"
,
ptr
:
new
(
*
big
.
Int
),
error
:
"rlp: expected input string or byte for *big.Int"
},
{
input
:
"C0"
,
ptr
:
new
(
*
big
.
Int
),
error
:
"rlp: expected input string or byte for *big.Int"
},
...
...
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