Skip to content

Commit

Permalink
Add assertion check for udp over tcp
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanson committed Oct 4, 2024
1 parent 2b9be05 commit a294b98
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions protocol/ashe/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import (
// | 1 |
// +------+
//
// - Code: 0x00: Succeed.
// - Code: 0x00: Succeed
// 0x01: General server failure

// Conf is acting as package level configuration.
Expand Down Expand Up @@ -75,11 +75,13 @@ func NewUDPConn(c io.ReadWriteCloser) *UDPConn {

// Read reads up to len(p) bytes into p.
func (c *UDPConn) Read(p []byte) (int, error) {
doa.Doa(len(p) >= 2)
_, err := io.ReadFull(c.ReadWriteCloser, p[:2])
if err != nil {
return 0, err
}
n := binary.BigEndian.Uint16(p[:2])
n := int(binary.BigEndian.Uint16(p[:2]))
doa.Doa(len(p) >= n)
return io.ReadFull(c.ReadWriteCloser, p[:n])
}

Expand Down

0 comments on commit a294b98

Please sign in to comment.