Skip to content

Commit

Permalink
Merge pull request #97 from lixin9311/packet_decryption_overlap_fix
Browse files Browse the repository at this point in the history
Fix the buffer overlap panic when read a udp/packet socket
  • Loading branch information
riobard authored Jun 28, 2018
2 parents ef4b562 + cc5b55c commit 26eb243
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion shadowstream/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func (c *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
if err != nil {
return n, addr, err
}
b, err = Unpack(b, b[:n], c.Cipher)
bb, err := Unpack(b[c.IVSize():], b[:n], c.Cipher)
if err != nil {
return n, addr, err
}
copy(b, bb)
return len(b), addr, err
}

0 comments on commit 26eb243

Please sign in to comment.