Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement similar fix to issue #225 (fixed in #388) for V1Decoder #1009

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/NetMQ/Core/Transports/V1Decoder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,18 +121,19 @@ private DecodeResult EightByteSizeReady()

// 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);
ulong payloadLength = m_tmpbuf.GetUnsignedLong(Endian, 0);

// There has to be at least one byte (the flags) in the message).
if (payloadLength == 0)
return DecodeResult.Error;

// Message size must not exceed the maximum allowed size.
if (m_maxMessageSize >= 0 && payloadLength - 1 > m_maxMessageSize)
if (m_maxMessageSize >= 0 && payloadLength - 1 > (ulong)m_maxMessageSize)
return DecodeResult.Error;

// TODO: move this constant to a good place (0x7FFFFFC7)
// Message size must fit within range of size_t data type.
if (payloadLength - 1 > int.MaxValue)
if (payloadLength - 1 > 0x7FFFFFC7)
return DecodeResult.Error;

int msgSize = (int)(payloadLength - 1);
Expand Down