Skip to content

Commit

Permalink
Fix RESERVED packets not being quickly rejected.
Browse files Browse the repository at this point in the history
Closes #2325
  • Loading branch information
ralight committed Oct 31, 2024
1 parent e852fd8 commit 0691935
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
2.0.21 - 2024-xx-xx
===================

Broker:
- Fix clients sending a RESERVED packet not being quickly disconnected.
Closes #2325.

Client library:
- Fix threads linking on Windows for static libmosquitto library
Closes #3143
Expand Down
1 change: 1 addition & 0 deletions include/mqtt_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ SPDX-License-Identifier: EPL-2.0 OR BSD-3-Clause


/* Message types */
#define CMD_RESERVED 0x00U
#define CMD_CONNECT 0x10U
#define CMD_CONNACK 0x20U
#define CMD_PUBLISH 0x30U
Expand Down
5 changes: 5 additions & 0 deletions lib/packet_mosq.c
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,11 @@ int packet__read(struct mosquitto *mosq)
/* Clients must send CONNECT as their first command. */
if(!(mosq->bridge) && state == mosq_cs_new && (byte&0xF0) != CMD_CONNECT){
return MOSQ_ERR_PROTOCOL;
}else if((byte&0xF0) == CMD_RESERVED){
if(mosq->protocol == mosq_p_mqtt5){
send__disconnect(mosq, MQTT_RC_PROTOCOL_ERROR, NULL);
}
return MOSQ_ERR_PROTOCOL;
}
#endif
}else{
Expand Down

0 comments on commit 0691935

Please sign in to comment.