Skip to content

Commit

Permalink
Fix heap overflow when reading corrupt config with "log_dest file".
Browse files Browse the repository at this point in the history
  • Loading branch information
ralight committed Aug 16, 2023
1 parent 284db04 commit 70d713c
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
1 change: 1 addition & 0 deletions ChangeLog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Broker:
not a string, when loading the dynsec config from file only.
- Dynsec plugin will not allow duplicate clients/groups/roles when loading
config from file, which matches the behaviour for when creating them.
- Fix heap overflow when reading corrupt config with "log_dest file".

Client library:
- Use CLOCK_BOOTTIME when available, to keep track of time. This solves the
Expand Down
10 changes: 6 additions & 4 deletions src/conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1533,15 +1533,16 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
}else if(!strcmp(token, "dlt")){
cr->log_dest |= MQTT3_LOG_DLT;
}else if(!strcmp(token, "file")){
cr->log_dest |= MQTT3_LOG_FILE;
if(config->log_fptr || config->log_file){
log__printf(NULL, MOSQ_LOG_ERR, "Error: Duplicate \"log_dest file\" value.");
return MOSQ_ERR_INVAL;
}
/* Get remaining string. */
token = &token[strlen(token)+1];
while(token[0] == ' ' || token[0] == '\t'){
token++;
token = saveptr;
if(token && token[0]){
while(token[0] == ' ' || token[0] == '\t'){
token++;
}
}
if(token[0]){
config->log_file = mosquitto__strdup(token);
Expand All @@ -1553,6 +1554,7 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
log__printf(NULL, MOSQ_LOG_ERR, "Error: Empty \"log_dest file\" value in configuration.");
return MOSQ_ERR_INVAL;
}
cr->log_dest |= MQTT3_LOG_FILE;
}else{
log__printf(NULL, MOSQ_LOG_ERR, "Error: Invalid log_dest value (%s).", token);
return MOSQ_ERR_INVAL;
Expand Down
1 change: 1 addition & 0 deletions src/handle_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -951,6 +951,7 @@ int handle__connect(struct mosquitto *context)


handle_connect_error:
mosquitto_property_free_all(&properties);
mosquitto__free(auth_data);
mosquitto__free(client_id);
mosquitto__free(username);
Expand Down

0 comments on commit 70d713c

Please sign in to comment.