Skip to content

Commit

Permalink
Fix packets read function
Browse files Browse the repository at this point in the history
  • Loading branch information
Holmus authored and Jakob Holmgren committed Apr 8, 2019
1 parent 4721b08 commit 09a30ac
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,15 @@ const (
ProductIDVLS128 ProductID = 0x63
)

// The exact number of blocks a packet must contain to be valid.
const numBlocks = 12

func (p *Packet) Read(r io.Reader) error {
if err := binary.Read(r, binary.LittleEndian, p); err != nil {
return err
}
// validate flags
for i := 0; i < len(p.Blocks); i++ {
for i := 0; i < numBlocks; i++ {
if p.Blocks[i].Flag != 0xeeff {
return errors.Errorf("invalid flag value %v in block %v", p.Blocks[i].Flag, i)
}
Expand Down

0 comments on commit 09a30ac

Please sign in to comment.