maidsafe-archive / socket-collection

Collection of sockets wrapped for convenience
BSD 3-Clause "New" or "Revised" License
6 stars 11 forks source link

fix TCP message decryption #32

Closed povilasb closed 5 years ago

povilasb commented 5 years ago

When data is read from socket, it is buffered. There might be multiple messages buffered at once. Even in such case TcpSock::read() should try to decrypt a single message whose length is known by the header. Unfortunately, that was not the case: read() attempted to decrypt a whole buffer and would fail utterly.

This fix makes sure we respect the message boundaries before trying to decrypt it.