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

[BUG] RECEIVE_MAXIMUM, TOPIC_ALIAS should be unsignedShort

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

Description

Please fill out the form below before submitting, thank you!

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

![image](https://github.com/eclipse/paho.mqtt.java/assets/18721508/787989c1-8115-4e87-a2fb-43c2984364f0)
According to the MQTT 5.0 protocol, RECEIVE_MAXIMUM should be in the range [0, 65535], but when the property is resolved, readShort() is used, which causes the range to be [-32768, 32767].
For example, if the server sends 65535(0xFFFF), the parsing will overflow and RECEIVE_MAXIMUM will be -1.

TOPIC_ALIAS_MAXIMUM and TOPIC_ALIAS the same as RECEIVE_MAXIMUM.

Contributor guide

Open the contributing guide

Research direction

Start by locating the MQTTv5 property-resolution path that uses readShort() for RECEIVE_MAXIMUM, TOPIC_ALIAS_MAXIMUM, and TOPIC_ALIAS. Compare its handling with the MQTT 5.0 unsignedShort range and inspect nearby parsing tests or callers. Done means values through 65535 parse without signed overflow, with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
networking
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
50/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.