File tree Expand file tree Collapse file tree 1 file changed +4
-3
lines changed
Expand file tree Collapse file tree 1 file changed +4
-3
lines changed Original file line number Diff line number Diff line change 11require " ./packets"
22
33module MQTT
4- MAX_REMAINING_LENGTH = (128 * 128 * 128 ).to_u32
4+ MAX_PAYLOAD_SIZE = 268_435_455 u32 # 256MiB
5+ MAX_MULTIPLIER = (128 * 128 * 128 ).to_u32
56
67 module Protocol
78 struct IO
89 getter io
910
1011 def self.new (io : ::IO , max_packet_size : UInt32 ? = nil ,
1112 byte_format = ::IO ::ByteFormat ::NetworkEndian )
12- new(io, max_packet_size || MAX_REMAINING_LENGTH , byte_format)
13+ new(io, max_packet_size || MAX_PAYLOAD_SIZE , byte_format)
1314 end
1415
1516 protected def initialize (@io : ::IO , @max_packet_size : UInt32 ,
@@ -56,7 +57,7 @@ module MQTT
5657 value += (b.to_u32 & 127 u32 ) * multiplier
5758 break if b & 128 == 0
5859 multiplier *= 128
59- raise Error ::PacketDecode .new " invalid remaining length" if multiplier > MAX_REMAINING_LENGTH
60+ raise Error ::PacketDecode .new " invalid remaining length" if multiplier > MAX_MULTIPLIER
6061 end
6162 raise Error ::PacketTooLarge .new(@max_packet_size , value) if value > @max_packet_size
6263 value
You can’t perform that action at this time.
0 commit comments