Merge pull request #138 from 251/acldos

Fix use-after-free (DOS) and small memory leak
This commit is contained in:
Roger Light 2016-05-14 23:07:16 +01:00
commit 19a9927661
2 changed files with 4 additions and 0 deletions

View File

@ -224,6 +224,7 @@ void mqtt3_config_cleanup(struct mqtt3_config *config)
if(config->persistence_file) _mosquitto_free(config->persistence_file);
if(config->persistence_filepath) _mosquitto_free(config->persistence_filepath);
if(config->psk_file) _mosquitto_free(config->psk_file);
if(config->pid_file) _mosquitto_free(config->pid_file);
if(config->listeners){
for(i=0; i<config->listener_count; i++){
if(config->listeners[i].host) _mosquitto_free(config->listeners[i].host);

View File

@ -549,6 +549,9 @@ int mqtt3_handle_connect(struct mosquitto_db *db, struct mosquitto *context)
msg_tail = msg_prev->next;
}else{
context->msgs = context->msgs->next;
if(context->last_msg == msg_tail){
context->last_msg = NULL;
}
_mosquitto_free(msg_tail);
msg_tail = context->msgs;
}