Fix heap overflow when reading config.

Closes oss-fuzz #57002.
pull/2743/merge
Roger A. Light 3 years ago
parent 94fbaa4fa1
commit 3fd5ba5f18

@ -1842,15 +1842,16 @@ static int config__read_file_core(struct mosquitto__config *config, bool reload,
cr->log_dest |= MQTT3_LOG_ANDROID;
#endif
}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);
@ -1862,6 +1863,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;

Loading…
Cancel
Save