You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, when the header gets serialised, it gets written as an variableLengthInteger, where it gets converted to an Int. When setting MQTTProperties.subscriptionIdentifier to a high enough value, this might crash with the fatal error Not enough bits to represent the passed value.
To Reproduce
Subscribe to a topic with an MQTTProperties.subscriptionIdentifier with an associated value Int.max<value<UInt.max, which compiles fine but result in a runtime crash because MQTTSerializer.variableLengthIntegerPacketSize wraps the value in an Int.
Expected behavior MQTTProperties.subscriptionIdentifier should either be declared as an Int or using an UInt should work without a crash.
Context (please complete the following information):
Platform macOS
Swift/Xcode Version: 5.7.2 / 14.2.0
Version 2.7.1
Additional context
The specification only defines the Subscription Identifier as Variable Byte Integer, so the associated value should probably be changed to an Int to prevent the crash.
The text was updated successfully, but these errors were encountered:
I'm not sure why I used a UInt when I should probably have used a UInt32 as I have elsewhere. I can add validation code in for the subscription id to ensure clients aren't sending an id that is too large.
Describe the bug
When subscribing to a value, I tried to generate a random
MQTTProperties.subscriptionIdentifier
using the lineHowever, this resulted in a runtime crash.
The subscription identifier is defined as
MQTTProperties.subscriptionIdentifier(UInt)
with an associated value ofUInt
.However, when the header gets serialised, it gets written as an
variableLengthInteger
, where it gets converted to anInt
. When settingMQTTProperties.subscriptionIdentifier
to a high enough value, this might crash with the fatal errorNot enough bits to represent the passed value
.To Reproduce
Subscribe to a topic with an
MQTTProperties.subscriptionIdentifier
with an associated valueInt.max<value<UInt.max
, which compiles fine but result in a runtime crash becauseMQTTSerializer.variableLengthIntegerPacketSize
wraps the value in anInt
.Expected behavior
MQTTProperties.subscriptionIdentifier
should either be declared as anInt
or using anUInt
should work without a crash.Context (please complete the following information):
Additional context
The specification only defines the Subscription Identifier as Variable Byte Integer, so the associated value should probably be changed to an
Int
to prevent the crash.The text was updated successfully, but these errors were encountered: