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
0c1888a3
Unverified
Commit
0c1888a3
authored
Sep 12, 2022
by
Seungbae Yu
Committed by
GitHub
Sep 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
p2p/discover/v5wire: reject packets smaller than 63 bytes (#25740)
parent
b628d727
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
3 deletions
+15
-3
encoding.go
p2p/discover/v5wire/encoding.go
+6
-2
encoding_test.go
p2p/discover/v5wire/encoding_test.go
+9
-1
No files found.
p2p/discover/v5wire/encoding.go
View file @
0c1888a3
...
...
@@ -90,6 +90,10 @@ const (
minVersion
=
1
sizeofMaskingIV
=
16
// The minimum size of any Discovery v5 packet is 63 bytes.
// Should reject packets smaller than minPacketSize.
minPacketSize
=
63
minMessageSize
=
48
// this refers to data after static headers
randomPacketMsgSize
=
20
)
...
...
@@ -415,10 +419,10 @@ func (c *Codec) encryptMessage(s *session, p Packet, head *Header, headerData []
// Decode decodes a discovery packet.
func
(
c
*
Codec
)
Decode
(
input
[]
byte
,
addr
string
)
(
src
enode
.
ID
,
n
*
enode
.
Node
,
p
Packet
,
err
error
)
{
// Unmask the static header.
if
len
(
input
)
<
sizeofStaticPacketData
{
if
len
(
input
)
<
minPacketSize
{
return
enode
.
ID
{},
nil
,
nil
,
errTooShort
}
// Unmask the static header.
var
head
Header
copy
(
head
.
IV
[
:
],
input
[
:
sizeofMaskingIV
])
mask
:=
head
.
mask
(
c
.
localnode
.
ID
())
...
...
p2p/discover/v5wire/encoding_test.go
View file @
0c1888a3
...
...
@@ -274,7 +274,15 @@ func TestDecodeErrorsV5(t *testing.T) {
net
:=
newHandshakeTest
()
defer
net
.
close
()
net
.
nodeA
.
expectDecodeErr
(
t
,
errTooShort
,
[]
byte
{})
b
:=
make
([]
byte
,
0
)
net
.
nodeA
.
expectDecodeErr
(
t
,
errTooShort
,
b
)
b
=
make
([]
byte
,
62
)
net
.
nodeA
.
expectDecodeErr
(
t
,
errTooShort
,
b
)
b
=
make
([]
byte
,
63
)
net
.
nodeA
.
expectDecodeErr
(
t
,
errInvalidHeader
,
b
)
// TODO some more tests would be nice :)
// - check invalid authdata sizes
// - check invalid handshake data sizes
...
...
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