eclipse-paho / eclipse-paho/paho.mqtt.javascript

Lack of handling on _requires_ack if this.store throws error leads to infinite this._message_identifier increment

Open
#260 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
1.2k
Forks
466
PR merge metrics
No merged PRs in 30d

Description

https://github.com/eclipse/paho.mqtt.javascript/blob/be026e0305f0ae5ed100015df25bbd20fac0a41b/src/paho-mqtt.js#L1201
should be
```javascript
if (this._message_identifier >= this.maxMessageIdentifier) {
```

because
```javascript
while(this._sentMessages[this._message_identifier] !== undefined) {
this._message_identifier++;
}
```
increments before this.store("Sent:", wireMessage); is called and this.store("Sent:", wireMessage); can throw an error, after which this._message_identifier remains incremented. Next time when this._requires_ack will be called it will be incremented again and this comparison will not work!

Contributor guide

Open the contributing guide

Research direction

Start at src/paho-mqtt.js around line 1201 and trace _requires_ack, the _message_identifier loop, and the this.store("Sent:", wireMessage) call. Reproduce or inspect the error path where store throws, then verify that a subsequent _requires_ack call handles the incremented identifier without looping indefinitely.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
networking
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.