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
b4a96d1c
Commit
b4a96d1c
authored
May 06, 2024
by
Levin Zimmermann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
go/proto/msgpack: Simplify debugging by printing function name in case of overflow
parent
012305fe
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
180 additions
and
173 deletions
+180
-173
go/neo/proto/msgpack.go
go/neo/proto/msgpack.go
+1
-1
go/neo/proto/proto-misc.go
go/neo/proto/proto-misc.go
+9
-0
go/neo/proto/proto.go
go/neo/proto/proto.go
+0
-4
go/neo/proto/proto_test.go
go/neo/proto/proto_test.go
+4
-2
go/neo/proto/protogen.go
go/neo/proto/protogen.go
+1
-1
go/neo/proto/zproto-marshal.go
go/neo/proto/zproto-marshal.go
+165
-165
No files found.
go/neo/proto/msgpack.go
View file @
b4a96d1c
...
...
@@ -44,7 +44,7 @@ func (e *mstructDecodeError) Error() string {
// mdecodeErr is called to normilize error when msgp.ReadXXX returns err when decoding path.
func
mdecodeErr
(
path
string
,
err
error
)
error
{
if
err
==
msgp
.
ErrShortBytes
{
return
ErrDecodeOverflow
return
&
ErrDecodeOverflow
{
path
}
}
return
&
mdecodeError
{
path
,
err
}
}
...
...
go/neo/proto/proto-misc.go
View file @
b4a96d1c
...
...
@@ -228,3 +228,12 @@ func (addr Address) String() string {
return
net
.
JoinHostPort
(
addr
.
Host
,
fmt
.
Sprintf
(
"%d"
,
addr
.
Port
))
}
}
// ErrDecodeOverflow is the error returned by neoMsgDecode when decoding hits buffer overflow
type
ErrDecodeOverflow
struct
{
function
string
}
func
(
e
*
ErrDecodeOverflow
)
Error
()
string
{
return
fmt
.
Sprintf
(
"decode '%s': buffer overflow"
,
e
.
function
)
}
go/neo/proto/proto.go
View file @
b4a96d1c
...
...
@@ -70,7 +70,6 @@ import (
"lab.nexedi.com/kirr/neo/go/internal/packed"
"encoding/binary"
"errors"
"math"
)
...
...
@@ -168,9 +167,6 @@ func (e Encoding) MsgDecode(msg Msg, data []byte) (nread int, err error) {
}
// ErrDecodeOverflow is the error returned by neoMsgDecode when decoding hits buffer overflow
var
ErrDecodeOverflow
=
errors
.
New
(
"decode: buffer overflow"
)
// ---- messages ----
//neo:proto enum
...
...
go/neo/proto/proto_test.go
View file @
b4a96d1c
...
...
@@ -22,6 +22,7 @@ package proto
import
(
"encoding/binary"
"errors"
hexpkg
"encoding/hex"
"fmt"
"reflect"
...
...
@@ -430,9 +431,10 @@ func TestMsgDecodeLenOverflowN(t *testing.T) {
}()
n
,
err
:=
enc
.
MsgDecode
(
tt
.
msg
,
data
)
if
!
(
n
==
0
&&
err
==
ErrDecodeOverflow
)
{
errDecodeOverflow
:=
new
(
ErrDecodeOverflow
)
if
!
(
n
==
0
&&
errors
.
As
(
err
,
&
errDecodeOverflow
))
{
t
.
Errorf
(
"%T: decode %x
\n
have: %d, %v
\n
want: %d, %v"
,
tt
.
msg
,
data
,
n
,
err
,
0
,
E
rrDecodeOverflow
)
n
,
err
,
0
,
e
rrDecodeOverflow
)
}
}()
}
...
...
go/neo/proto/protogen.go
View file @
b4a96d1c
...
...
@@ -917,7 +917,7 @@ func (d *decoderCommon) generatedCode() string {
// NOTE for >0 check actual X in StdSizes{X} does not particularly matter
if
((
&
types
.
StdSizes
{
8
,
8
})
.
Sizeof
(
d
.
typ
)
>
0
||
d
.
enc
!=
'N'
)
&&
d
.
overflow
.
gotoEmitted
{
code
.
emit
(
"
\n
overflow:"
)
code
.
emit
(
"return 0,
ErrDecodeOverflow"
)
code
.
emit
(
"return 0,
&ErrDecodeOverflow{
\"
%s
\"
}"
,
d
.
typeName
)
}
code
.
emit
(
"}
\n
"
)
...
...
go/neo/proto/zproto-marshal.go
View file @
b4a96d1c
This diff is collapsed.
Click to expand it.
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