Skip to content

Commit

Permalink
Fix the overlap problem of udp decryption.
Browse files Browse the repository at this point in the history
Now return the correct length of data read by ReadFrom.
  • Loading branch information
lixin9311 committed Aug 29, 2018
1 parent 18fc4a9 commit 89e875b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions shadowaead/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,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)
return len(b), addr, err
bb, err := Unpack(b[c.Cipher.SaltSize():], b[:n], c)
if err != nil {
return n, addr, err
}
copy(b, bb)
return len(bb), addr, err
}
2 changes: 1 addition & 1 deletion shadowstream/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,5 +76,5 @@ func (c *packetConn) ReadFrom(b []byte) (int, net.Addr, error) {
return n, addr, err
}
copy(b, bb)
return len(b), addr, err
return len(bb), addr, err
}

0 comments on commit 89e875b

Please sign in to comment.