Commit d3a2925b authored by Rob Pike's avatar Rob Pike

catch corruption - avoid crash

R=rsc
DELTA=4  (4 added, 0 deleted, 0 changed)
OCL=31192
CL=31198
parent deb95477
...@@ -295,6 +295,10 @@ func decodeStruct(engine *decEngine, rtyp reflect.StructType, r io.Reader, p uin ...@@ -295,6 +295,10 @@ func decodeStruct(engine *decEngine, rtyp reflect.StructType, r io.Reader, p uin
basep := p; basep := p;
for state.err == nil { for state.err == nil {
delta := int(DecodeUint(state)); delta := int(DecodeUint(state));
if delta < 0 {
state.err = os.ErrorString("gob decode: corrupted data: negative delta");
break
}
if state.err != nil || delta == 0 { // struct terminator is zero delta fieldnum if state.err != nil || delta == 0 { // struct terminator is zero delta fieldnum
break break
} }
......
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