From 50dbbce372274f5830d916203dcb25ee1ffe0c15 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Fri, 31 Jan 2025 19:10:59 -0500
Subject: [PATCH] Fix inverted comparisons in SUB and UNSUB messages

---
 exec/broker.js | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/exec/broker.js b/exec/broker.js
index c0e34c950f..6d8146f586 100644
--- a/exec/broker.js
+++ b/exec/broker.js
@@ -2227,7 +2227,7 @@ MQTT.Packet.SUBSCRIBE.prototype.recv = function(conn) {
 		var tfilter = conn.getUTF8String();
 		var sopts = new MQTT.Connection.SubscriptionOptions(conn.getByte());
 		this.payload.push({topic_filter: tfilter, subscription_options: sopts});
-	} while ((start_len - conn.rx_buf.length) > this.pkt_length);
+	} while ((start_len - conn.rx_buf.length) < this.pkt_length);
 };
 
 // MQTT.Packet.SUBACK class
@@ -2280,7 +2280,7 @@ MQTT.Packet.UNSUBSCRIBE.prototype.recv = function(conn) {
 
 	do {
 		this.payload.push(conn.getUTF8String());
-	} while ((start_len - conn.rx_buf.length) > this.pkt_length);
+	} while ((start_len - conn.rx_buf.length) < this.pkt_length);
 };
 
 // MQTT.Packet.UNSUBACK class
-- 
GitLab