Skip to content

Commit

Permalink
Remove STRICT_PROTOCOL #ifdefs.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed May 31, 2014
1 parent 1984e2e commit 87579e0
Show file tree
Hide file tree
Showing 8 changed files with 2 additions and 100 deletions.
2 changes: 2 additions & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Broker:
- Fix bug #1324411, which could have had unexpected consequences for delayed
messages in rare circumstances.
- Add support for "session present" in CONNACK messages for MQTT v3.1.1.
- Remove strict protocol #ifdefs.

Clients:
- Both clients can now load default configuration options from a file.
Expand All @@ -29,6 +30,7 @@ Client library:
- Fix callback deadlocks after calling mosquitto_disconnect(), when using the
threaded interfaces. Closes bug #1313725.
- Fix SRV support when building with CMake.
- Remove strict protocol #ifdefs.

General:
- Use $(STRIP) for stripping binaries when installing, to allow easier cross
Expand Down
14 changes: 0 additions & 14 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ WITH_TLS_PSK:=yes
# Comment out to disable client client threading support.
WITH_THREADING:=yes

# Uncomment to compile the broker with strict protocol support. This means that
# both the client library and the broker will be very strict about protocol
# compliance on incoming data. Neither of them will return an error on
# incorrect "remaining length" values if this is commented out. The old
# behaviour (prior to 0.12) is equivalent to compiling with
# WITH_STRICT_PROTOCOL defined and means that clients will be immediately
# disconnected from the broker on non-compliance.
#WITH_STRICT_PROTOCOL:=yes

# Comment out to remove bridge support from the broker. This allow the broker
# to connect to other brokers and subscribe/publish to topics. You probably
# want to leave this included unless you want to save a very small amount of
Expand Down Expand Up @@ -183,11 +174,6 @@ ifeq ($(WITH_THREADING),yes)
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_THREADING
endif

ifeq ($(WITH_STRICT_PROTOCOL),yes)
LIB_CFLAGS:=$(LIB_CFLAGS) -DWITH_STRICT_PROTOCOL
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_STRICT_PROTOCOL
endif

ifeq ($(WITH_BRIDGE),yes)
BROKER_CFLAGS:=$(BROKER_CFLAGS) -DWITH_BRIDGE
endif
Expand Down
5 changes: 0 additions & 5 deletions lib/read_handle_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,6 @@ int _mosquitto_handle_connack(struct mosquitto *mosq)
int rc;

assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
_mosquitto_log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK", mosq->id);
rc = _mosquitto_read_byte(&mosq->in_packet, &byte); // Reserved byte, not used
if(rc) return rc;
Expand Down
30 changes: 0 additions & 30 deletions lib/read_handle_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,6 @@ and the Eclipse Distribution License is available at
int _mosquitto_handle_pingreq(struct mosquitto *mosq)
{
assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 0){
return MOSQ_ERR_PROTOCOL;
}
#endif
#ifdef WITH_BROKER
_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received PINGREQ from %s", mosq->id);
#else
Expand All @@ -50,11 +45,6 @@ int _mosquitto_handle_pingreq(struct mosquitto *mosq)
int _mosquitto_handle_pingresp(struct mosquitto *mosq)
{
assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 0){
return MOSQ_ERR_PROTOCOL;
}
#endif
mosq->ping_t = 0; /* No longer waiting for a PINGRESP. */
#ifdef WITH_BROKER
_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received PINGRESP from %s", mosq->id);
Expand All @@ -70,11 +60,6 @@ int _mosquitto_handle_pubackcomp(struct mosquitto *mosq, const char *type)
int rc;

assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
rc = _mosquitto_read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
#ifdef WITH_BROKER
Expand Down Expand Up @@ -108,11 +93,6 @@ int _mosquitto_handle_pubrec(struct mosquitto *mosq)
int rc;

assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
rc = _mosquitto_read_uint16(&mosq->in_packet, &mid);
if(rc) return rc;
#ifdef WITH_BROKER
Expand Down Expand Up @@ -140,11 +120,6 @@ int _mosquitto_handle_pubrel(struct mosquitto_db *db, struct mosquitto *mosq)
int rc;

assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
if(mosq->protocol == mosq_p_mqtt311){
if((mosq->in_packet.command&0x0F) != 0x02){
return MOSQ_ERR_PROTOCOL;
Expand Down Expand Up @@ -231,11 +206,6 @@ int _mosquitto_handle_unsuback(struct mosquitto *mosq)
int rc;

assert(mosq);
#ifdef WITH_STRICT_PROTOCOL
if(mosq->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
#ifdef WITH_BROKER
_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received UNSUBACK from %s", mosq->id);
#else
Expand Down
5 changes: 0 additions & 5 deletions src/read_handle_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@ int mqtt3_handle_connack(struct mosquitto_db *db, struct mosquitto *context)
if(!context){
return MOSQ_ERR_INVAL;
}
#ifdef WITH_STRICT_PROTOCOL
if(context->in_packet.remaining_length != 2){
return MOSQ_ERR_PROTOCOL;
}
#endif
_mosquitto_log_printf(NULL, MOSQ_LOG_DEBUG, "Received CONNACK on connection %s.", context->id);
if(_mosquitto_read_byte(&context->in_packet, &byte)) return 1; // Reserved byte, not used
if(_mosquitto_read_byte(&context->in_packet, &rc)) return 1;
Expand Down
4 changes: 0 additions & 4 deletions src/read_handle_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,7 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context)
}

slen = strlen(client_id);
#ifdef WITH_STRICT_PROTOCOL
if(slen > 23 || slen == 0){
#else
if(slen == 0){
#endif
if(context->protocol == mosq_p_mqtt31){
_mosquitto_free(client_id);
_mosquitto_send_connack(context, 0, CONNACK_REFUSED_IDENTIFIER_REJECTED);
Expand Down
39 changes: 0 additions & 39 deletions test/broker/01-connect-invalid-id-24.py

This file was deleted.

3 changes: 0 additions & 3 deletions test/broker/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,3 @@ test : test-compile 01 02 03 04 05 06 07 08 09 10
10 :
./10-listener-mount-point.py

# Tests for with WITH_STRICT_PROTOCOL defined
strict-test :
./01-connect-invalid-id-24.py

0 comments on commit 87579e0

Please sign in to comment.