Skip to content

Commit

Permalink
Fix: Proper Blockwise Handling for Initial GET and DELETE Requests
Browse files Browse the repository at this point in the history
Corrected the handling of initial requests for GET and DELETE operations in
the CoAP blockwise implementation. Previously, the code allowed the use of
message types Acknowledge (ACK) or Reset (RST) for the initial request.
  • Loading branch information
jkralik committed Jan 17, 2024
1 parent c61c648 commit 27368bd
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions net/blockwise/blockwise.go
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,10 @@ func (b *BlockWise[C]) handleReceivedMessage(w *responsewriter.ResponseWriter[C]
next(w, r)
return nil
case codes.GET, codes.DELETE:
// For GET and DELETE requests in CoAP, the initial request cannot have the message type of Acknowledge (ACK) or Reset (RST)
if r.Type() == message.Acknowledgement || r.Type() == message.Reset {
return fmt.Errorf("invalid message type(%v) for code(%v)", r.Type(), r.Code())
}
maxSZX = fitSZX(r, message.Block2, maxSZX)
block, errG := r.GetOptionUint32(message.Block2)
if errG == nil {
Expand Down

0 comments on commit 27368bd

Please sign in to comment.