good morning!!!!
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Erigon
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Harbor Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
a
Erigon
Commits
cefd9482
Commit
cefd9482
authored
9 years ago
by
Felix Lange
Browse files
Options
Downloads
Patches
Plain Diff
rlp: reject trailing data when using DecodeBytes
parent
593b1b65
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
rlp/decode.go
+13
-1
13 additions, 1 deletion
rlp/decode.go
with
13 additions
and
1 deletion
rlp/decode.go
+
13
−
1
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"
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment