diff options
Diffstat (limited to 'config.c')
-rw-r--r-- | config.c | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -2,6 +2,7 @@ #include <stdint.h> #include <stdlib.h> #include <string.h> +#include <syslog.h> #include "config.h" char *read_file(const char *filename, long *size) { @@ -152,6 +153,16 @@ config *parse_config(const char *filename) { /* Is the config option valid? */ if (opt->name != NULL) { config_val val = parse_option_value(opt, value); + if (opt->offset == offsetof(config, port)) { + const int port = strtol(val.str, NULL, 0); + if (port <= 0 || port > 65535) { + syslog(LOG_ERR, "Invalid port %d. (Valid port must be between 1, and 65535.)", port); + cleanup_config(cfg); + free(line); + free(buf); + return NULL; + } + } set_config_opt(cfg, opt->type, opt->offset, val); } |