Skip to content

Commit

Permalink
Fix the return of plugin__handle_message not being fully handled.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed May 21, 2021
1 parent 90e3b28 commit 0e1388a
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/handle_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,11 @@ int handle__publish(struct mosquitto *context)
/* Check for topic access */
rc = mosquitto_acl_check(context, msg->topic, msg->payloadlen, msg->payload, msg->qos, msg->retain, MOSQ_ACL_WRITE);
if(rc == MOSQ_ERR_ACL_DENIED){
log__printf(NULL, MOSQ_LOG_DEBUG, "Denied PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))", context->id, dup, msg->qos, msg->retain, msg->source_mid, msg->topic, (long)msg->payloadlen);
reason_code = MQTT_RC_NOT_AUTHORIZED;
log__printf(NULL, MOSQ_LOG_DEBUG,
"Denied PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))",
context->id, dup, msg->qos, msg->retain, msg->source_mid, msg->topic,
(long)msg->payloadlen);
reason_code = MQTT_RC_NOT_AUTHORIZED;
goto process_bad_message;
}else if(rc != MOSQ_ERR_SUCCESS){
db__msg_store_free(msg);
Expand All @@ -260,23 +263,22 @@ int handle__publish(struct mosquitto *context)
db__msg_store_free(msg);
return rc;
#else
if(msg->qos == 1){
if (send__puback(context, msg->source_mid, MQTT_RC_SUCCESS, NULL)) {
return MOSQ_ERR_UNKNOWN;
}
}else if(msg->qos == 2){
if(send__pubrec(context, msg->source_mid, MQTT_RC_SUCCESS, NULL)){
return MOSQ_ERR_UNKNOWN;
}
}
db__msg_store_free(msg);
return MOSQ_ERR_SUCCESS;
reason_code = MQTT_RC_IMPLEMENTATION_SPECIFIC;
goto process_bad_message;
#endif
}

{
rc = plugin__handle_message(context, msg);
if(rc){
if(rc == MOSQ_ERR_ACL_DENIED){
log__printf(NULL, MOSQ_LOG_DEBUG,
"Denied PUBLISH from %s (d%d, q%d, r%d, m%d, '%s', ... (%ld bytes))",
context->id, dup, msg->qos, msg->retain, msg->source_mid, msg->topic,
(long)msg->payloadlen);

reason_code = MQTT_RC_NOT_AUTHORIZED;
goto process_bad_message;
}else if(rc != MOSQ_ERR_SUCCESS){
db__msg_store_free(msg);
return rc;
}
Expand Down

0 comments on commit 0e1388a

Please sign in to comment.