Commit 2cd55b6f authored by Kirill Smelkov's avatar Kirill Smelkov

X dumb way to check for decode overflow

parent 47999e52
This diff is collapsed.
...@@ -297,6 +297,7 @@ func (e *encoder) genBasic(path string, typ *types.Basic, userType types.Type, o ...@@ -297,6 +297,7 @@ func (e *encoder) genBasic(path string, typ *types.Basic, userType types.Type, o
func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Type, obj types.Object) { func (d *decoder) genBasic(assignto string, typ *types.Basic, userType types.Type, obj types.Object) {
basic := basicTypes[typ.Kind()] basic := basicTypes[typ.Kind()]
d.emit("if len(data) < %v { goto overflow }", d.n + basic.wireSize)
dataptr := fmt.Sprintf("data[%v:]", d.n) dataptr := fmt.Sprintf("data[%v:]", d.n)
decoded := fmt.Sprintf(basic.decode, dataptr) decoded := fmt.Sprintf(basic.decode, dataptr)
d.n += basic.wireSize d.n += basic.wireSize
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment