|
|
|
@ -67,19 +67,28 @@ int handle__subscribe(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
|
|
|
|
|
if(sub){
|
|
|
|
|
if(STREMPTY(sub)){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO, "Empty subscription string from %s, disconnecting.",
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO,
|
|
|
|
|
"Empty subscription string from %s, disconnecting.",
|
|
|
|
|
context->address);
|
|
|
|
|
mosquitto__free(sub);
|
|
|
|
|
mosquitto__free(payload);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if(mosquitto_sub_topic_check(sub)){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO, "Invalid subscription string from %s, disconnecting.",
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO,
|
|
|
|
|
"Invalid subscription string from %s, disconnecting.",
|
|
|
|
|
context->address);
|
|
|
|
|
mosquitto__free(sub);
|
|
|
|
|
mosquitto__free(payload);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if(mosquitto_validate_utf8(sub, strlen(sub))){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO,
|
|
|
|
|
"Malformed UTF-8 in subscription string from %s, disconnecting.",
|
|
|
|
|
context->id);
|
|
|
|
|
mosquitto__free(sub);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(packet__read_byte(&context->in_packet, &qos)){
|
|
|
|
|
mosquitto__free(sub);
|
|
|
|
@ -87,7 +96,8 @@ int handle__subscribe(struct mosquitto_db *db, struct mosquitto *context)
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
if(qos > 2){
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO, "Invalid QoS in subscription command from %s, disconnecting.",
|
|
|
|
|
log__printf(NULL, MOSQ_LOG_INFO,
|
|
|
|
|
"Invalid QoS in subscription command from %s, disconnecting.",
|
|
|
|
|
context->address);
|
|
|
|
|
mosquitto__free(sub);
|
|
|
|
|
mosquitto__free(payload);
|
|
|
|
|