TokTok / c-toxcore

The future of online communications.
https://tox.chat
GNU General Public License v3.0
2.21k stars 280 forks source link

Friend requests with very long messages are ignored #2719

Open JFreegman opened 3 months ago

JFreegman commented 3 months ago

If you send a friend request through the onion with a message over a certain threshold but still under TOX_MAX_FRIEND_REQUEST_LENGTH, the request will succeed on the sender's side, but be dropped on the receiving side. This is because the length of the request packet is too large for the onion data packet handler.

The fix: Reduce MAX_FRIEND_REQUEST_DATA_SIZE and TOX_MAX_FRIEND_REQUEST_LENGTH so that the maximum possible packet size received by handle_data_response() is <= MAX_DATA_REQUEST_SIZE. The length check in send_friend_request_packet() also needs to be adjusted to match the new value.

The bigger fix: The onion shouldn't be able to send packets that are too large to be handled.