Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
N
neoppod
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Levin Zimmermann
neoppod
Commits
32f40833
Commit
32f40833
authored
Aug 20, 2024
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! go/proto/msgpack: Simplify debugging by printing function name in case of overflow
parent
eda58438
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
10 deletions
+22
-10
go/neo/proto/proto_test.go
go/neo/proto/proto_test.go
+2
-1
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+3
-1
go/neo/proto/zproto-marshal.go
go/neo/proto/zproto-marshal.go
+17
-8
No files found.
go/neo/proto/proto_test.go
View file @
32f40833
...
...
@@ -153,7 +153,8 @@ func testMsgMarshal(t *testing.T, enc Encoding, msg Msg, encoded string) {
// decode must detect buffer overflow
for
l
:=
len
(
encoded
)
-
1
;
l
>=
0
;
l
--
{
n
,
err
=
enc
.
MsgDecode
(
msg2
,
data
[
:
l
])
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
!
(
n
==
0
&&
errors
.
As
(
err
,
&
errDecodeOverflow
))
{
t
.
Errorf
(
"%c/%v: decode overflow not detected on [:%v]"
,
enc
,
typ
,
l
)
}
...
...
go/neo/proto/protogen.go
View file @
32f40833
...
...
@@ -320,6 +320,7 @@ package proto
import (
"encoding/binary"
"errors"
"math"
"reflect"
"sort"
...
...
@@ -1155,7 +1156,8 @@ func (d *decoderM) genBasic(assignto string, typ *types.Basic, userType types.Ty
// correct float, but data is too short - catch this to return
// 'ErrDecodeOverflow' instead of type error.
d
.
emit
(
" err = mdecodeErr(%q, err)"
,
d
.
pathName
(
assignto
))
d
.
emit
(
" if err == ErrDecodeOverflow {"
)
d
.
emit
(
" errDecodeOverflow := new(ErrDecodeOverflow)"
)
d
.
emit
(
" if errors.As(err, &errDecodeOverflow) {"
)
d
.
emit
(
" return 0, err"
)
d
.
emit
(
" }"
)
d
.
emit
(
" tail, err = msgp.ReadNilBytes(data)"
)
...
...
go/neo/proto/zproto-marshal.go
View file @
32f40833
...
...
@@ -6,6 +6,7 @@ package proto
import
(
"encoding/binary"
"errors"
"math"
"reflect"
"sort"
...
...
@@ -420,7 +421,8 @@ func (p *RequestIdentification) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadFloat64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"RequestIdentification.IdTime"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -1124,7 +1126,8 @@ func (p *NotifyNodeInformation) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadFloat64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"NotifyNodeInformation.IdTime"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -1228,7 +1231,8 @@ func (p *NotifyNodeInformation) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadFloat64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"NotifyNodeInformation.IdTime"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -4969,7 +4973,8 @@ func (p *AnswerRebaseObject) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadUint64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"AnswerRebaseObject.Compression"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -5190,7 +5195,8 @@ func (p *StoreObject) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadUint64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"StoreObject.Compression"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -6241,7 +6247,8 @@ func (p *AnswerObject) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadUint64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"AnswerObject.Compression"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -7777,7 +7784,8 @@ func (p *AnswerNodeList) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadFloat64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"AnswerNodeList.IdTime"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
@@ -13194,7 +13202,8 @@ func (p *AddObject) neoMsgDecodeM(data []byte) (int, error) {
v
,
tail
,
err
:=
msgp
.
ReadUint64Bytes
(
data
)
if
err
!=
nil
{
err
=
mdecodeErr
(
"AddObject.Compression"
,
err
)
if
err
==
ErrDecodeOverflow
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
errors
.
As
(
err
,
&
errDecodeOverflow
)
{
return
0
,
err
}
tail
,
err
=
msgp
.
ReadNilBytes
(
data
)
...
...
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