From 0257cf7ba624830840f9634e35ab9a507b85ef31 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Thu, 15 Oct 2015 11:36:00 +0200 Subject: Bail out if config file is not readable --- ldadp.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'ldadp.c') diff --git a/ldadp.c b/ldadp.c index a47fba0..b1a5a73 100644 --- a/ldadp.c +++ b/ldadp.c @@ -15,7 +15,7 @@ #include static void listen_callback(void *data, int haveIn, int haveOut, int doCleanup); -static void loadConfig(char *file); +static BOOL loadConfig(char *file); static int localPort = 1234; static char *certFile = NULL, *keyFile = NULL; @@ -34,7 +34,7 @@ int main(int argc, char **argv) argv++; argc--; } - loadConfig(argv[1]); + if (!loadConfig(argv[1])) bail("Cannot read config file %s", argv[1]); if (localPort < 1 || localPort > 65535) bail("Invalid port given in config"); proxy_init(); char listen_addr[4] = {0, 0, 0, 0}; @@ -138,8 +138,8 @@ static int loadConfig_handler(void *stuff, const char *section, const char *key, return 1; } -static void loadConfig(char *file) +static BOOL loadConfig(char *file) { - ini_parse(file, &loadConfig_handler, NULL); + return ini_parse(file, &loadConfig_handler, NULL) >= 0; } -- cgit v1.2.3-55-g7522