[bug] Entire TCP packet being received as a single command #1

Closed
opened 2022-01-01 13:58:31 -06:00 by lemonsh · 1 comment

async-circe currently uses AsyncReadExt::read() to read a line from the TCP stream, but that method in no way guarantees how many bytes it will read. Effectively, this can lead to a complete desynchronization of the protocol exchange if read() happens to finish even one byte before the CRLF.

Here's an example of circe reading an optimized (by the IRCd) TCP packet containing multiple messages:

2022-01-01T19:34:18.405477Z DEBUG async_circe::commands: 0466737e393c.karx.xyz 375 uberbot2 :0466737e393c.karx.xyz message of the day
:0466737e393c.karx.xyz 372 uberbot2 :          _                     ___ ____   ____ 
:0466737e393c.karx.xyz 372 uberbot2 :         | | ____ _ _ ____  __ |_ _|  _ \ / ___|
:0466737e393c.karx.xyz 372 uberbot2 :         | |/ / _` | '__\ \/ /  | || |_) | |    
:0466737e393c.karx.xyz 372 uberbot2 :         |   < (_| | |   >  <   | ||  _ <| |___ 
:0466737e393c.karx.xyz 372 uberbot2 :         |_|\_\__,_|_|  /_/\_\ |___|_| \_\____|

where one log message corresponds to many actual IRC messages.

async-circe currently uses AsyncReadExt::read() to read a line from the TCP stream, but that method in no way guarantees how many bytes it will read. Effectively, this can lead to a complete desynchronization of the protocol exchange if read() happens to finish even one byte before the CRLF. Here's an example of circe reading an optimized (by the IRCd) TCP packet containing multiple messages: ``` 2022-01-01T19:34:18.405477Z DEBUG async_circe::commands: 0466737e393c.karx.xyz 375 uberbot2 :0466737e393c.karx.xyz message of the day :0466737e393c.karx.xyz 372 uberbot2 : _ ___ ____ ____ :0466737e393c.karx.xyz 372 uberbot2 : | | ____ _ _ ____ __ |_ _| _ \ / ___| :0466737e393c.karx.xyz 372 uberbot2 : | |/ / _` | '__\ \/ / | || |_) | | :0466737e393c.karx.xyz 372 uberbot2 : | < (_| | | > < | || _ <| |___ :0466737e393c.karx.xyz 372 uberbot2 : |_|\_\__,_|_| /_/\_\ |___|_| \_\____| ``` where one log message corresponds to many actual IRC messages.
Owner

fixed by #df4a7a7ce

fixed by #df4a7a7ce
famfo closed this issue 2022-01-02 02:59:12 -06:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: circe/async-circe#1
No description provided.