diff options
Diffstat (limited to 'other')
-rw-r--r-- | other/bootstrap_daemon/tox_bootstrap_daemon.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/other/bootstrap_daemon/tox_bootstrap_daemon.c b/other/bootstrap_daemon/tox_bootstrap_daemon.c index 8d3ed94a..dce181a4 100644 --- a/other/bootstrap_daemon/tox_bootstrap_daemon.c +++ b/other/bootstrap_daemon/tox_bootstrap_daemon.c | |||
@@ -62,6 +62,9 @@ | |||
62 | #define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false | 62 | #define DEFAULT_ENABLE_LAN_DISCOVERY 1 // 1 - true, 0 - false |
63 | #define DEFAULT_ENABLE_TCP_RELAY 1 | 63 | #define DEFAULT_ENABLE_TCP_RELAY 1 |
64 | 64 | ||
65 | #define MIN_ALLOWED_PORT 1 | ||
66 | #define MAX_ALLOWED_PORT 65535 | ||
67 | |||
65 | 68 | ||
66 | // Uses the already existing key or creates one if it didn't exist | 69 | // Uses the already existing key or creates one if it didn't exist |
67 | // | 70 | // |
@@ -156,8 +159,8 @@ void parse_tcp_relay_ports_config(config_t *cfg, uint16_t **tcp_relay_ports, int | |||
156 | } | 159 | } |
157 | 160 | ||
158 | (*tcp_relay_ports)[*tcp_relay_port_count] = config_setting_get_int(elem); | 161 | (*tcp_relay_ports)[*tcp_relay_port_count] = config_setting_get_int(elem); |
159 | if ((*tcp_relay_ports)[i] < 1 || (*tcp_relay_ports)[i] > 65535) { | 162 | if ((*tcp_relay_ports)[i] < MIN_ALLOWED_PORT || (*tcp_relay_ports)[i] > MAX_ALLOWED_PORT) { |
160 | syslog(LOG_WARNING, "Port #%d: Invalid port value, should be in [1, 65535]. Skipping.\n", i); | 163 | syslog(LOG_WARNING, "Port #%d: Invalid port value, should be in [%d, %d]. Skipping.\n", i, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); |
161 | continue; | 164 | continue; |
162 | } | 165 | } |
163 | 166 | ||
@@ -359,9 +362,8 @@ int bootstrap_from_config(char *cfg_file_path, DHT *dht, int enable_ipv6) | |||
359 | goto next; | 362 | goto next; |
360 | } | 363 | } |
361 | 364 | ||
362 | // not (1 <= port <= 65535) | 365 | if (bs_port < MIN_ALLOWED_PORT || bs_port > MAX_ALLOWED_PORT) { |
363 | if (bs_port < 1 || bs_port > 65535) { | 366 | syslog(LOG_WARNING, "Bootstrap node #%d: Invalid '%s': %d, should be in [%d, %d]. Skipping the node.\n", i, NAME_PORT, bs_port, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); |
364 | syslog(LOG_WARNING, "Bootstrap node #%d: Invalid '%s': %d. Skipping the node.\n", i, NAME_PORT, bs_port); | ||
365 | goto next; | 367 | goto next; |
366 | } | 368 | } |
367 | 369 | ||
@@ -437,9 +439,8 @@ int main(int argc, char *argv[]) | |||
437 | return 1; | 439 | return 1; |
438 | } | 440 | } |
439 | 441 | ||
440 | // not (1 <= port <= 65535) | 442 | if (port < MIN_ALLOWED_PORT || port > MAX_ALLOWED_PORT) { |
441 | if (port < 1 || port > 65535) { | 443 | syslog(LOG_ERR, "Invalid port: %d, should be in [%d, %d]. Exiting.\n", port, MIN_ALLOWED_PORT, MAX_ALLOWED_PORT); |
442 | syslog(LOG_ERR, "Invalid port: %d, must be 1 <= port <= 65535. Exiting.\n", port); | ||
443 | return 1; | 444 | return 1; |
444 | } | 445 | } |
445 | 446 | ||