eclipse / paho.mqtt.java

Eclipse Paho Java MQTT client library. Paho is an Eclipse IoT project.
https://eclipse.org/paho
Other
2.1k stars 880 forks source link

Receive Maximum property should be interpreted as an unsigned short integer #976

Open freyssin opened 1 year ago

freyssin commented 1 year ago

The MQTT v5 specification defines the Receive Maximum property as a Two Byte Integer (16-bit unsigned integers).

The Receive Maximum property is currently decoded by a call to DataInput.readShort casted to int (see MqttProperties.decodeProperties). This code interprets any value greater than 32767 as a negative value.

The MqttDataTypes.readUnsignedTwoByteInt method should be used instead.

The same problem is present in the encoding of the value, and presumably in the encoding/decoding of several other values: