summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorRoberto Hueso Gómez <rhueso@soleta.eu>2020-07-13 10:36:36 +0200
committerOpenGnSys Support Team <soporte-og@soleta.eu>2020-07-15 12:47:45 +0200
commita8e5b844c5ea1c0e2c8339870739298ecaedcf69 (patch)
tree234ec9cbe1a8c31ef2eb339f916ef6b54cc380d5 /src
parent0631b0e8e6fdf77d0bbe6715e0cb2c4bdb872b12 (diff)
#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.
Diffstat (limited to 'src')
-rw-r--r--src/cfg.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/cfg.c b/src/cfg.c
index d19ab15..c9ed435 100644
--- a/src/cfg.c
+++ b/src/cfg.c
@@ -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);