From b9c6c96f800cfcc73d5767d66ffdfe235d5865ff Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Sat, 30 Jul 2022 12:00:40 -0300 Subject: config: Use string instead of int in `check_port()` oof, forgot that `config.port` is a string. --- config.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/config.c b/config.c index 012ed3d..30e3e95 100644 --- a/config.c +++ b/config.c @@ -20,14 +20,15 @@ void cleanup_config(config *conf) { } int check_port(void *ctx, void *ret, const keyword *key, keyword_val val) { - if (key->type == TYPE_INT) { - if (val.i > 0 || val.i <= 65535) { + if (key->type == TYPE_STRING) { + int port = strtol(val.str, NULL, 0); + if (port > 0 || port <= 65535) { return 0; } else { - log(LOG_ERR, "Invalid port %d. (Valid port must be between 1, and 65535.)", val.i); + log(LOG_ERR, "Invalid port %d. (Valid port must be between 1, and 65535.)", port); } } else { - log(LOG_ERR, "Keyword \"%s\" doesn't return an integer.", key->key); + log(LOG_ERR, "Keyword \"%s\" doesn't return a string.", key->key); } return -1; } -- cgit v1.2.3-13-gbd6f