#988 Check DB port size is in [0, UINT16_MAX]

Max port number is UINT16_MAX, so this checks whether this config
parameter is in the correct range.
master
Roberto Hueso Gómez 2020-07-13 10:36:36 +02:00 committed by OpenGnSys Support Team
parent 0631b0e8e6
commit a8e5b844c5
1 changed files with 2 additions and 1 deletions

View File

@ -58,7 +58,8 @@ static int parse_json_db(struct og_server_cfg *cfg, json_t *element)
if (og_json_parse_string(value, &cfg->db.name) < 0)
return -1;
} else if (!strcmp(key, "port")) {
if (og_json_parse_uint(value, &cfg->db.port) < 0)
if (og_json_parse_uint(value, &cfg->db.port) < 0 ||
cfg->db.port > UINT16_MAX)
return -1;
} else {
syslog(LOG_ERR, "unknown key `%s' in db\n", key);