eclipse-paho / eclipse-paho/paho.mqtt.java

Receive Maximum property should be interpreted as an unsigned short integer

Open
#976 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
2.3k
Forks
919
PR merge metrics
No merged PRs in 30d

Description

- [X] Bug exists Release Version 1.2.5 ( Master Branch)
- [X] Bug exists in MQTTv5 Client on Snapshot Version 1.2.6-SNAPSHOT (Develop Branch)

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](https://github.com/eclipse/paho.mqtt.java/blob/master/org.eclipse.paho.mqttv5.client/src/main/java/org/eclipse/paho/mqttv5/common/packet/MqttProperties.java#L473)). 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:
- length of Auth Data, or Correlation Data (Binary Data, section 1.5.6 of the specification).
- value of Topic Alias Maximum, Topic Alias identifier.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.