Remove STRICT_PROTOCOL #ifdefs.

pull/211/merge
Roger A. Light 11 years ago
parent 1984e2e37d
commit 87579e0cac

@ -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.
@ -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

@ -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
@ -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

@ -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;

@ -34,11 +34,6 @@ Contributors:
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
@ -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);
@ -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
@ -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
@ -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;
@ -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

@ -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;

@ -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);

@ -1,39 +0,0 @@
#!/usr/bin/env python
# Test whether a CONNECT with a too-long client id results in the correct CONNACK packet.
import subprocess
import socket
import time
import inspect, os, sys
# From http://stackoverflow.com/questions/279237/python-import-a-module-from-a-folder
cmd_subfolder = os.path.realpath(os.path.abspath(os.path.join(os.path.split(inspect.getfile( inspect.currentframe() ))[0],"..")))
if cmd_subfolder not in sys.path:
sys.path.insert(0, cmd_subfolder)
import mosq_test
rc = 1
keepalive = 10
connect_packet = mosq_test.gen_connect("connect-invalid-id-test-", keepalive=keepalive)
connack_packet = mosq_test.gen_connack(rc=2)
broker = subprocess.Popen(['../../src/mosquitto', '-p', '1888'], stderr=subprocess.PIPE)
try:
time.sleep(0.5)
sock = mosq_test.do_client_connect(connect_packet, connack_packet)
sock.close()
rc = 0
finally:
broker.terminate()
broker.wait()
if rc:
(stdo, stde) = broker.communicate()
print(stde)
exit(rc)

@ -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

Loading…
Cancel
Save