Skip to content

Commit

Permalink
decoder: ipfix have max size (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
lspgn authored Dec 1, 2023
1 parent 9287e05 commit ac5e849
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion decoders/netflow/netflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -374,8 +374,10 @@ func DecodeMessageContext(ctx context.Context, payload *bytes.Buffer, templateKe
} else {
return nil, fmt.Errorf("NetFlow/IPFIX version error: %d", version)
}
read := 16
startSize := payload.Len()

for i := 0; ((i < int(size) && version == 9) || version == 10) && payload.Len() > 0; i++ {
for i := 0; ((i < int(size) && version == 9) || (uint16(read) < size && version == 10)) && payload.Len() > 0; i++ {
fsheader := FlowSetHeader{}
if err := utils.BinaryDecoder(payload, &fsheader.Id, &fsheader.Length); err != nil {
return returnItem, fmt.Errorf("Error decoding FlowSet header: %v", err)
Expand Down Expand Up @@ -522,6 +524,7 @@ func DecodeMessageContext(ctx context.Context, payload *bytes.Buffer, templateKe
} else if version == 10 && flowSet != nil {
packetIPFIX.FlowSets = append(packetIPFIX.FlowSets, flowSet)
}
read = startSize - payload.Len() + 16
}

if version == 9 {
Expand Down

0 comments on commit ac5e849

Please sign in to comment.