CHAT_FILE_BLOCK bugs

Posted by Glorimus on Thu 13 Oct 2016 09:09 AM — 2 posts, 10,829 views.

#0
The current chat file block protocol has a few bugs in ..

1) it doesn't handle the end of the file correctly.
Specifically this line in ChatSock::OnReceive

          // must have file block size + 2 (command and terminator)
          // otherwise we will get them later
          if (iLength < (m_iFileBlockSize + 2))
            return;

this expects the file to always to be of blocksize 500

2) it goes against the protocol. according to
Quote:

<CHAT_FILE_BLOCK><block of data>

A file block is 500 bytes. A file block is ALWAYS 500 bytes so no CHAT_END_OF_COMMAND is needed.


there should be no end byte, but the code in ChatSock expects it

 // discard the file block and message number and terminator byte
          m_outstanding_input = m_outstanding_input.Mid (m_iFileBlockSize + 2);
#1
btw, I found a workaround.

I padded the file up until 500 bytes, but kept the filesize the original size. This gets me past the first if check of blocksize +2, but only the filesize % 500 gets written