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
cefd9482
Commit
cefd9482
authored
Jul 17, 2015
by
Felix Lange
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rlp: reject trailing data when using DecodeBytes
parent
593b1b65
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
1 deletion
+13
-1
decode.go
rlp/decode.go
+13
-1
No files found.
rlp/decode.go
View file @
cefd9482
...
...
@@ -110,9 +110,17 @@ func Decode(r io.Reader, val interface{}) error {
// DecodeBytes parses RLP data from b into val.
// Please see the documentation of Decode for the decoding rules.
// The input must contain exactly one value and no trailing data.
func
DecodeBytes
(
b
[]
byte
,
val
interface
{})
error
{
// TODO: this could use a Stream from a pool.
return
NewStream
(
bytes
.
NewReader
(
b
),
uint64
(
len
(
b
)))
.
Decode
(
val
)
r
:=
bytes
.
NewReader
(
b
)
if
err
:=
NewStream
(
r
,
uint64
(
len
(
b
)))
.
Decode
(
val
);
err
!=
nil
{
return
err
}
if
r
.
Len
()
>
0
{
return
ErrMoreThanOneValue
}
return
nil
}
type
decodeError
struct
{
...
...
@@ -517,6 +525,10 @@ var (
ErrElemTooLarge
=
errors
.
New
(
"rlp: element is larger than containing list"
)
ErrValueTooLarge
=
errors
.
New
(
"rlp: value size exceeds available input length"
)
// This error is reported by DecodeBytes if the slice contains
// additional data after the first RLP value.
ErrMoreThanOneValue
=
errors
.
New
(
"rlp: input contains more than one value"
)
// internal errors
errNotInList
=
errors
.
New
(
"rlp: call of ListEnd outside of any list"
)
errNotAtEOL
=
errors
.
New
(
"rlp: call of ListEnd not positioned at EOL"
)
...
...
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