private bool EightByteSizeReady() { m_tmpbuf.Reset(); // 8-byte payload length is read. Allocate the buffer // for message body and read the message data into it. long payloadLength = m_tmpbuf.GetLong(Endian, 0); // There has to be at least one byte (the flags) in the message). if (payloadLength == 0) { DecodingError(); return(false); } // Message size must not exceed the maximum allowed size. if (m_maxmsgsize >= 0 && payloadLength - 1 > m_maxmsgsize) { DecodingError(); return(false); } // Message size must fit within range of size_t data type. if (payloadLength - 1 > int.MaxValue) { DecodingError(); return(false); } int msgSize = (int)(payloadLength - 1); // in_progress is initialized at this point so in theory we should // close it before calling init_size, however, it's a 0-byte // message and thus we can treat it as uninitialized... m_inProgress.InitPool(msgSize); NextStep(m_tmpbuf, 1, FlagsReadyState); return(true); }
private bool EightByteSizeReady() { m_tmpbuf.Reset(); // The payload size is encoded as 64-bit unsigned integer. // The most significant byte comes first. long msg_size = m_tmpbuf.GetLong(Endian, 0); // Message size must not exceed the maximum allowed size. if (m_maxmsgsize >= 0) { if (msg_size > m_maxmsgsize) { DecodingError(); return(false); } } // Message size must fit within range of size_t data type. if (msg_size > int.MaxValue) { DecodingError(); return(false); } // in_progress is initialised at this point so in theory we should // close it before calling init_size, however, it's a 0-byte // message and thus we can treat it as uninitialised. m_inProgress.InitPool((int)msg_size); m_inProgress.SetFlags(m_msgFlags); NextStep(m_inProgress.Data, m_inProgress.Size, MessageReadyState); return(true); }