diff --git a/ChangeLog.txt b/ChangeLog.txt index 0b458670..81fd892e 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -15,6 +15,8 @@ Broker: Closes #1718. - Fix "slow" file based logging by switching to line based buffering. Closes #1689. Closes #1741. +- Log protocol error message where appropriate from a bad UNSUBSCRIBE, rather + than the generic "socket error". Client library: - Improved documentation around connect callback return codes. Close #1730. diff --git a/src/handle_unsubscribe.c b/src/handle_unsubscribe.c index 9869b32a..df27911d 100644 --- a/src/handle_unsubscribe.c +++ b/src/handle_unsubscribe.c @@ -49,7 +49,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) return MOSQ_ERR_PROTOCOL; } } - if(packet__read_uint16(&context->in_packet, &mid)) return 1; + if(packet__read_uint16(&context->in_packet, &mid)) return MOSQ_ERR_PROTOCOL; if(mid == 0) return MOSQ_ERR_PROTOCOL; if(context->protocol == mosq_p_mqtt5){ @@ -76,7 +76,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) sub = NULL; if(packet__read_string(&context->in_packet, &sub, &slen)){ mosquitto__free(reason_codes); - return 1; + return MOSQ_ERR_PROTOCOL; } if(!slen){ @@ -85,7 +85,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) context->id); mosquitto__free(sub); mosquitto__free(reason_codes); - return 1; + return MOSQ_ERR_PROTOCOL; } if(mosquitto_sub_topic_check(sub)){ log__printf(NULL, MOSQ_LOG_INFO, @@ -93,7 +93,7 @@ int handle__unsubscribe(struct mosquitto_db *db, struct mosquitto *context) context->id); mosquitto__free(sub); mosquitto__free(reason_codes); - return 1; + return MOSQ_ERR_PROTOCOL; } log__printf(NULL, MOSQ_LOG_DEBUG, "\t%s", sub);