paho.mqtt.javascript icon indicating copy to clipboard operation
paho.mqtt.javascript copied to clipboard

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

Open elcreator opened this issue 1 year ago • 0 comments

https://github.com/eclipse/paho.mqtt.javascript/blob/be026e0305f0ae5ed100015df25bbd20fac0a41b/src/paho-mqtt.js#L1201 should be

 if (this._message_identifier >= this.maxMessageIdentifier) { 

because

			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!

elcreator avatar Oct 03 '24 22:10 elcreator