Skip to content

Commit

Permalink
Issue503 (#543)
Browse files Browse the repository at this point in the history
* regeneration after pull #537

* issue503 test. better determined packed varint size
  • Loading branch information
jmarais authored Feb 18, 2019
1 parent 00e1f47 commit 53c36c5
Show file tree
Hide file tree
Showing 76 changed files with 6,322 additions and 227 deletions.
50 changes: 48 additions & 2 deletions plugin/unmarshal/unmarshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,11 @@ func (p *unmarshal) mapField(varName string, customType bool, field *descriptor.
p.Out()
p.P(`}`)
p.P(`postStringIndex`, varName, ` := iNdEx + intStringLen`, varName)
p.P(`if postStringIndex`, varName, ` < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postStringIndex`, varName, ` > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand All @@ -386,7 +391,7 @@ func (p *unmarshal) mapField(varName string, customType bool, field *descriptor.
p.Out()
p.P(`}`)
p.P(`postmsgIndex := iNdEx + mapmsglen`)
p.P(`if mapmsglen < 0 {`)
p.P(`if postmsgIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
Expand Down Expand Up @@ -440,6 +445,11 @@ func (p *unmarshal) mapField(varName string, customType bool, field *descriptor.
p.Out()
p.P(`}`)
p.P(`postbytesIndex := iNdEx + intMapbyteLen`)
p.P(`if postbytesIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postbytesIndex > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -632,6 +642,11 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
p.Out()
p.P(`}`)
p.P(`postIndex := iNdEx + intStringLen`)
p.P(`if postIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postIndex > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -661,6 +676,11 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
p.Out()
p.P(`}`)
p.P(`postIndex := iNdEx + msglen`)
p.P(`if postIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postIndex > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -1110,6 +1130,11 @@ func (p *unmarshal) field(file *generator.FileDescriptor, msg *generator.Descrip
p.Out()
p.P(`}`)
p.P(`postIndex := iNdEx + byteLen`)
p.P(`if postIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postIndex > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -1364,6 +1389,11 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
p.Out()
p.P(`}`)
p.P(`postIndex := iNdEx + packedLen`)
p.P(`if postIndex < 0 {`)
p.In()
p.P(`return ErrInvalidLength` + p.localName)
p.Out()
p.P(`}`)
p.P(`if postIndex > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -1459,6 +1489,11 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
p.P(`return ErrInvalidLength`, p.localName)
p.Out()
p.P(`}`)
p.P(`if (iNdEx + skippy) < 0 {`)
p.In()
p.P(`return ErrInvalidLength`, p.localName)
p.Out()
p.P(`}`)
p.P(`if (iNdEx + skippy) > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand All @@ -1482,6 +1517,11 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
p.P(`return ErrInvalidLength`, p.localName)
p.Out()
p.P(`}`)
p.P(`if (iNdEx + skippy) < 0 {`)
p.In()
p.P(`return ErrInvalidLength`, p.localName)
p.Out()
p.P(`}`)
p.P(`if (iNdEx + skippy) > l {`)
p.In()
p.P(`return `, p.ioPkg.Use(), `.ErrUnexpectedEOF`)
Expand Down Expand Up @@ -1589,10 +1629,13 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
break
}
}
iNdEx += length
if length < 0 {
return 0, ErrInvalidLength` + p.localName + `
}
iNdEx += length
if iNdEx < 0 {
return 0, ErrInvalidLength` + p.localName + `
}
return iNdEx, nil
case 3:
for {
Expand Down Expand Up @@ -1621,6 +1664,9 @@ func (p *unmarshal) Generate(file *generator.FileDescriptor) {
return 0, err
}
iNdEx = start + next
if iNdEx < 0 {
return 0, ErrInvalidLength` + p.localName + `
}
}
return iNdEx, nil
case 4:
Expand Down
17 changes: 16 additions & 1 deletion test/asymetric-issue125/asym.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 46 additions & 4 deletions test/casttype/combos/both/casttype.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 53c36c5

Please sign in to comment.