Coverity Scan issues.
1436823 1436837 1436843 1432792 1436847 1436848 1436849
This commit is contained in:
parent
f83fcc8535
commit
0c6365726f
@ -269,6 +269,15 @@ static int dump__msg_store_chunk_process(FILE *db_fptr, uint32_t length)
|
||||
}
|
||||
|
||||
stored = mosquitto__calloc(1, sizeof(struct mosquitto_msg_store));
|
||||
if(stored == NULL){
|
||||
mosquitto__free(load);
|
||||
fclose(db_fptr);
|
||||
mosquitto__free(chunk.source.id);
|
||||
mosquitto__free(chunk.source.username);
|
||||
mosquitto__free(chunk.topic);
|
||||
UHPA_FREE(chunk.payload, chunk.F.payloadlen);
|
||||
return MOSQ_ERR_NOMEM;
|
||||
}
|
||||
stored->source_mid = chunk.F.source_mid;
|
||||
stored->topic = chunk.topic;
|
||||
stored->qos = chunk.F.qos;
|
||||
@ -286,12 +295,9 @@ static int dump__msg_store_chunk_process(FILE *db_fptr, uint32_t length)
|
||||
chunk.source.username = NULL;
|
||||
|
||||
if(rc == MOSQ_ERR_SUCCESS){
|
||||
/*
|
||||
printf("stored:%p\n", stored);
|
||||
stored->source_listener = chunk.source.listener;
|
||||
load->db_id = stored->db_id;
|
||||
load->store = stored;
|
||||
*/
|
||||
|
||||
HASH_ADD(hh, db.msg_store_load, db_id, sizeof(dbid_t), load);
|
||||
}else{
|
||||
@ -455,7 +461,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Warning: Unsupported chunk \"%d\" in persistent database file. Ignoring.\n", chunk);
|
||||
fseek(fd, length, SEEK_CUR);
|
||||
if(fseek(fd, length, SEEK_CUR) < 0){
|
||||
fprintf(stderr, "Error seeking in file.\n");
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -486,7 +495,7 @@ int main(int argc, char *argv[])
|
||||
return rc;
|
||||
error:
|
||||
fprintf(stderr, "Error: %s.", strerror(errno));
|
||||
if(fd >= 0) fclose(fd);
|
||||
if(fd) fclose(fd);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -504,19 +504,21 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(username && strlen(username) > 65535){
|
||||
fprintf(stderr, "Error: Username must be less than 65536 characters long.\n");
|
||||
return 1;
|
||||
if(username){
|
||||
if(strlen(username) > 65535){
|
||||
fprintf(stderr, "Error: Username must be less than 65536 characters long.\n");
|
||||
return 1;
|
||||
}
|
||||
if(strchr(username, ':')){
|
||||
fprintf(stderr, "Error: Username must not contain the ':' character.\n");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if(password_cmd && strlen(password_cmd) > 65535){
|
||||
fprintf(stderr, "Error: Password must be less than 65536 characters long.\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(strchr(username, ':')){
|
||||
fprintf(stderr, "Error: Username must not contain the ':' character.\n");
|
||||
return 1;
|
||||
}
|
||||
#ifdef WIN32
|
||||
password_file = _fullpath(NULL, password_file_tmp, 0);
|
||||
if(!password_file){
|
||||
|
@ -471,7 +471,9 @@ void dynsec__config_save(void)
|
||||
fclose(fptr);
|
||||
|
||||
/* Everything is ok, so move new file over proper file */
|
||||
rename(file_path, config_file);
|
||||
if(rename(file_path, config_file) < 0){
|
||||
mosquitto_log_printf(MOSQ_LOG_ERR, "Error updating dynsec config file: %s", strerror(errno));
|
||||
}
|
||||
mosquitto_free(file_path);
|
||||
}
|
||||
|
||||
|
@ -568,7 +568,7 @@ int main(int argc, char *argv[])
|
||||
mosquitto_security_module_cleanup();
|
||||
|
||||
if(config.pid_file){
|
||||
remove(config.pid_file);
|
||||
(void)remove(config.pid_file);
|
||||
}
|
||||
|
||||
log__close(&config);
|
||||
|
@ -645,7 +645,8 @@ static int net__socket_listen_tcp(struct mosquitto__listener *listener)
|
||||
|
||||
#ifndef WIN32
|
||||
ss_opt = 1;
|
||||
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &ss_opt, sizeof(ss_opt));
|
||||
/* Unimportant if this fails */
|
||||
(void)setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &ss_opt, sizeof(ss_opt));
|
||||
#endif
|
||||
#ifdef IPV6_V6ONLY
|
||||
ss_opt = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user