Skip to content

Commit

Permalink
return nils when EOF or last option
Browse files Browse the repository at this point in the history
  • Loading branch information
RicYaben committed Jul 24, 2024
1 parent 9bc35e6 commit 0aa9efb
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions modules/coap/message/option.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/binary"
"errors"
"fmt"
"io"
)

Expand Down Expand Up @@ -105,12 +104,12 @@ func (o *Options) Unmarshal(buf *bytes.Buffer) error {
for buf.Len() > 0 {
b, err := buf.ReadByte()
if err == io.EOF {
return err
break // end of file
}

delta, length := int(b>>4), int(b&0x0F)
if delta == 0x0F && length == 0x0F {
return fmt.Errorf("invalid delta")
break // end of message
}

delta, err = o.parseExtOpt(buf, delta)
Expand Down

0 comments on commit 0aa9efb

Please sign in to comment.