From ac5808207e7dd0174b2439b1d4b226a3b6735bd5 Mon Sep 17 00:00:00 2001 From: Richard Heatley Date: Thu, 24 Mar 2022 11:37:03 +0000 Subject: [PATCH] Implement similar fix to issue #225 (fixed in #388) for V1Decoder --- src/NetMQ/Core/Transports/V1Decoder.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/NetMQ/Core/Transports/V1Decoder.cs b/src/NetMQ/Core/Transports/V1Decoder.cs index e455916a5..c98510083 100644 --- a/src/NetMQ/Core/Transports/V1Decoder.cs +++ b/src/NetMQ/Core/Transports/V1Decoder.cs @@ -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);