diff options
author | Simon Rettberg | 2017-11-02 10:52:14 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-11-02 10:52:14 +0100 |
commit | 7b60dec40999eb86666426c0b03c1a847b147ece (patch) | |
tree | f48ba8655c4bacd5ce6fef3e0742ff706499d2eb | |
parent | [SERVER] Clean up arguments, show version on startup (diff) | |
download | dnbd3-7b60dec40999eb86666426c0b03c1a847b147ece.tar.gz dnbd3-7b60dec40999eb86666426c0b03c1a847b147ece.tar.xz dnbd3-7b60dec40999eb86666426c0b03c1a847b147ece.zip |
[SERVER] Ignore invalid basePath in globals.c, do bailout in server.c
-rw-r--r-- | src/server/globals.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/server/globals.c b/src/server/globals.c index 4939101..d6f077b 100644 --- a/src/server/globals.c +++ b/src/server/globals.c @@ -62,16 +62,19 @@ void globals_loadConfig() // Validate settings after loading: // base path for images valid? if ( _basePath == NULL || _basePath[0] == '\0' ) { - logadd( LOG_ERROR, "Need to specify basePath in " CONFIG_FILENAME ); - exit( EXIT_FAILURE ); - } - if ( _basePath[0] != '/' ) { - logadd( LOG_ERROR, "_basePath must be absolute!" ); - exit( EXIT_FAILURE ); + logadd( LOG_WARNING, "No/empty basePath in " CONFIG_FILENAME ); + free( _basePath ); + _basePath = NULL; + } else if ( _basePath[0] != '/' ) { + logadd( LOG_WARNING, "basePath must be absolute!" ); + free( _basePath ); + _basePath = NULL; + } else { + char *end = _basePath + strlen( _basePath ) - 1; + while ( end >= _basePath && *end == '/' ) { + *end-- = '\0'; + } } - char *end = _basePath + strlen( _basePath ) - 1; - while ( end >= _basePath && *end == '/' ) - *end-- = '\0'; // listen port if ( _listenPort < 1 || _listenPort > 65535 ) { logadd( LOG_ERROR, "listenPort must be 1-65535, but is %d", _listenPort ); |