Skip to content

Commit

Permalink
Merge pull request #692 from SailorStu/fix-Receive-panic
Browse files Browse the repository at this point in the history
Fixed Receive Panic if h.MessageSize < hdrlen bytes.
  • Loading branch information
kung-foo committed Oct 17, 2023
2 parents fd06ca1 + d06cdc3 commit 41e54cf
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion uacp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ func (c *Conn) Receive() ([]byte, error) {
}

if h.MessageSize > c.ack.ReceiveBufSize {
return nil, errors.Errorf("uacp: message too large: %d > %d bytes", h.MessageSize, c.ack.ReceiveBufSize)
return nil, errors.Errorf("uacp: message too large: %d > %d bytes. MsgType=%s, ChunkType=%c", h.MessageSize, c.ack.ReceiveBufSize, h.MessageType, h.ChunkType)
}
if h.MessageSize < hdrlen {
return nil, errors.Errorf("uacp: message too small: %d bytes. MsgType=%s, ChunkType=%c.", h.MessageSize, h.MessageType, h.ChunkType)
}

if _, err := io.ReadFull(c, b[hdrlen:h.MessageSize]); err != nil {
Expand Down

0 comments on commit 41e54cf

Please sign in to comment.