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
2750ec47
Commit
2750ec47
authored
Apr 13, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rlp: fix integer overflow in list element size validation
It is not safe to add anything to s.size.
parent
56a48101
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
decode.go
rlp/decode.go
+2
-2
decode_test.go
rlp/decode_test.go
+3
-0
No files found.
rlp/decode.go
View file @
2750ec47
...
...
@@ -751,7 +751,7 @@ func (s *Stream) Kind() (kind Kind, size uint64, err error) {
tos
=
&
s
.
stack
[
len
(
s
.
stack
)
-
1
]
}
if
s
.
kind
<
0
{
//
d
on't read further if we're at the end of the
//
D
on't read further if we're at the end of the
// innermost list.
if
tos
!=
nil
&&
tos
.
pos
==
tos
.
size
{
return
0
,
0
,
EOL
...
...
@@ -772,7 +772,7 @@ func (s *Stream) Kind() (kind Kind, size uint64, err error) {
}
}
else
{
// Inside a list, check that the value doesn't overflow the list.
if
tos
.
pos
+
s
.
size
>
tos
.
size
{
if
s
.
size
>
tos
.
size
-
tos
.
pos
{
return
0
,
0
,
ErrElemTooLarge
}
}
...
...
rlp/decode_test.go
View file @
2750ec47
...
...
@@ -112,6 +112,9 @@ func TestStreamErrors(t *testing.T) {
{
"BFFFFFFFFFFFFFFFFFFF"
,
calls
{
"Bytes"
},
nil
,
ErrValueTooLarge
},
{
"C801"
,
calls
{
"List"
},
nil
,
ErrValueTooLarge
},
// Test for list element size check overflow.
{
"CD04040404FFFFFFFFFFFFFFFFFF0303"
,
calls
{
"List"
,
"Uint"
,
"Uint"
,
"Uint"
,
"Uint"
,
"List"
},
nil
,
ErrElemTooLarge
},
// Test for input limit overflow. Since we are counting the limit
// down toward zero in Stream.remaining, reading too far can overflow
// remaining to a large value, effectively disabling the limit.
...
...
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