Skip to content

Commit

Permalink
Fix AEAD buffer overlap bug
Browse files Browse the repository at this point in the history
  • Loading branch information
riobard committed Sep 27, 2018
1 parent c25b1d1 commit 1191fd9
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions shadowaead/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,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
}
8 changes: 6 additions & 2 deletions 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)
return len(b), addr, err
bb, err := Unpack(b[c.IVSize():], b[:n], c.Cipher)
if err != nil {
return n, addr, err
}
copy(b, bb)
return len(bb), addr, err
}

0 comments on commit 1191fd9

Please sign in to comment.