summaryrefslogtreecommitdiff
path: root/other/bootstrap_daemon/src/config.c
diff options
context:
space:
mode:
Diffstat (limited to 'other/bootstrap_daemon/src/config.c')
-rw-r--r--other/bootstrap_daemon/src/config.c24
1 files changed, 13 insertions, 11 deletions
diff --git a/other/bootstrap_daemon/src/config.c b/other/bootstrap_daemon/src/config.c
index 27d1364a..3e102af9 100644
--- a/other/bootstrap_daemon/src/config.c
+++ b/other/bootstrap_daemon/src/config.c
@@ -62,7 +62,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
62 } 62 }
63 63
64 // similar procedure to the one of reading config file below 64 // similar procedure to the one of reading config file below
65 *tcp_relay_ports = malloc(DEFAULT_TCP_RELAY_PORTS_COUNT * sizeof(uint16_t)); 65 *tcp_relay_ports = (uint16_t *)malloc(DEFAULT_TCP_RELAY_PORTS_COUNT * sizeof(uint16_t));
66 66
67 for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) { 67 for (i = 0; i < DEFAULT_TCP_RELAY_PORTS_COUNT; i ++) {
68 68
@@ -80,7 +80,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
80 80
81 // the loop above skips invalid ports, so we adjust the allocated memory size 81 // the loop above skips invalid ports, so we adjust the allocated memory size
82 if ((*tcp_relay_port_count) > 0) { 82 if ((*tcp_relay_port_count) > 0) {
83 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); 83 *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
84 } else { 84 } else {
85 free(*tcp_relay_ports); 85 free(*tcp_relay_ports);
86 *tcp_relay_ports = NULL; 86 *tcp_relay_ports = NULL;
@@ -102,7 +102,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
102 return; 102 return;
103 } 103 }
104 104
105 *tcp_relay_ports = malloc(config_port_count * sizeof(uint16_t)); 105 *tcp_relay_ports = (uint16_t *)malloc(config_port_count * sizeof(uint16_t));
106 106
107 int i; 107 int i;
108 108
@@ -134,7 +134,7 @@ static void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_por
134 134
135 // the loop above skips invalid ports, so we adjust the allocated memory size 135 // the loop above skips invalid ports, so we adjust the allocated memory size
136 if ((*tcp_relay_port_count) > 0) { 136 if ((*tcp_relay_port_count) > 0) {
137 *tcp_relay_ports = realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t)); 137 *tcp_relay_ports = (uint16_t *)realloc(*tcp_relay_ports, (*tcp_relay_port_count) * sizeof(uint16_t));
138 } else { 138 } else {
139 free(*tcp_relay_ports); 139 free(*tcp_relay_ports);
140 *tcp_relay_ports = NULL; 140 *tcp_relay_ports = NULL;
@@ -182,7 +182,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
182 tmp_pid_file = DEFAULT_PID_FILE_PATH; 182 tmp_pid_file = DEFAULT_PID_FILE_PATH;
183 } 183 }
184 184
185 *pid_file_path = malloc(strlen(tmp_pid_file) + 1); 185 *pid_file_path = (char *)malloc(strlen(tmp_pid_file) + 1);
186 strcpy(*pid_file_path, tmp_pid_file); 186 strcpy(*pid_file_path, tmp_pid_file);
187 187
188 // Get keys file location 188 // Get keys file location
@@ -194,7 +194,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
194 tmp_keys_file = DEFAULT_KEYS_FILE_PATH; 194 tmp_keys_file = DEFAULT_KEYS_FILE_PATH;
195 } 195 }
196 196
197 *keys_file_path = malloc(strlen(tmp_keys_file) + 1); 197 *keys_file_path = (char *)malloc(strlen(tmp_keys_file) + 1);
198 strcpy(*keys_file_path, tmp_keys_file); 198 strcpy(*keys_file_path, tmp_keys_file);
199 199
200 // Get IPv6 option 200 // Get IPv6 option
@@ -254,7 +254,7 @@ int get_general_config(const char *cfg_file_path, char **pid_file_path, char **k
254 254
255 size_t tmp_motd_length = strlen(tmp_motd) + 1; 255 size_t tmp_motd_length = strlen(tmp_motd) + 1;
256 size_t motd_length = tmp_motd_length > MAX_MOTD_LENGTH ? MAX_MOTD_LENGTH : tmp_motd_length; 256 size_t motd_length = tmp_motd_length > MAX_MOTD_LENGTH ? MAX_MOTD_LENGTH : tmp_motd_length;
257 *motd = malloc(motd_length); 257 *motd = (char *)malloc(motd_length);
258 strncpy(*motd, tmp_motd, motd_length); 258 strncpy(*motd, tmp_motd, motd_length);
259 (*motd)[motd_length - 1] = '\0'; 259 (*motd)[motd_length - 1] = '\0';
260 } 260 }
@@ -310,7 +310,7 @@ static uint8_t *hex_string_to_bin(const char *hex_string)
310 } 310 }
311 311
312 size_t len = strlen(hex_string) / 2; 312 size_t len = strlen(hex_string) / 2;
313 uint8_t *ret = malloc(len); 313 uint8_t *ret = (uint8_t *)malloc(len);
314 314
315 const char *pos = hex_string; 315 const char *pos = hex_string;
316 size_t i; 316 size_t i;
@@ -364,6 +364,8 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
364 int i = 0; 364 int i = 0;
365 365
366 while (config_setting_length(node_list)) { 366 while (config_setting_length(node_list)) {
367 int address_resolved;
368 uint8_t *bs_public_key_bin;
367 369
368 node = config_setting_get_elem(node_list, 0); 370 node = config_setting_get_elem(node_list, 0);
369 371
@@ -403,9 +405,9 @@ int bootstrap_from_config(const char *cfg_file_path, DHT *dht, int enable_ipv6)
403 goto next; 405 goto next;
404 } 406 }
405 407
406 uint8_t *bs_public_key_bin = hex_string_to_bin(bs_public_key); 408 bs_public_key_bin = hex_string_to_bin(bs_public_key);
407 const int address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port), 409 address_resolved = DHT_bootstrap_from_address(dht, bs_address, enable_ipv6, htons(bs_port),
408 bs_public_key_bin); 410 bs_public_key_bin);
409 free(bs_public_key_bin); 411 free(bs_public_key_bin);
410 412
411 if (!address_resolved) { 413 if (!address_resolved) {