Skip to content

Commit

Permalink
Check wireType too
Browse files Browse the repository at this point in the history
  • Loading branch information
amaury1093 committed Jul 22, 2021
1 parent 84443c9 commit 002f2c1
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions x/auth/tx/decoder.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,13 @@ func rejectNonADR027(txBytes []byte) error {
prevTagNum := protowire.Number(0)

for len(txBytes) > 0 {
tagNum, _, m := protowire.ConsumeTag(txBytes)
tagNum, wireType, m := protowire.ConsumeTag(txBytes)
if m < 0 {
return fmt.Errorf("invalid length; %w", protowire.ParseError(m))
}

if wireType != protowire.BytesType {
return fmt.Errorf("expected %d wire type, got %d", protowire.VarintType, wireType)
}
if tagNum < prevTagNum {
return fmt.Errorf("txRaw must follow ADR-027, got tagNum %d after tagNum %d", tagNum, prevTagNum)
}
Expand Down

0 comments on commit 002f2c1

Please sign in to comment.