From: Klemens Nanni Date: Tue, 30 Jan 2024 02:43:44 +0000 (+0100) Subject: Exit on config read error to avoid crash on EACCES X-Git-Tag: 4.3.4-dev~48^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad1fc121ebaa6f7109d23555ad27d3a0e2d0a840;p=thirdparty%2Fshairport-sync.git Exit on config read error to avoid crash on EACCES Failure to read does not exit despite ` /* Read the file. If there is an error, report it and exit. */` EACCES (e.g. insufficient filesystem permissions) is enough to crash on access through later `config_*()` such as those when either of either of D-Bus, MPRIS or MQTT is used. Seen `--with-mpris-interface` and ``` $ ls -l /etc/shairport-sync.conf -rw-r----- 1 root _shairport 28114 Jan 25 01:53 /etc/shairport-sync.conf $ shairport-sync Segmentation fault (core dumped) ``` --- diff --git a/shairport.c b/shairport.c index 4ced2392..bded4165 100644 --- a/shairport.c +++ b/shairport.c @@ -1207,8 +1207,8 @@ int parse_options(int argc, char **argv) { } else { if (config_error_type(&config_file_stuff) == CONFIG_ERR_FILE_IO) - debug(2, "Error reading configuration file \"%s\": \"%s\".", - config_error_file(&config_file_stuff), config_error_text(&config_file_stuff)); + die("Error reading configuration file \"%s\": \"%s\".", + config_file_real_path, config_error_text(&config_file_stuff)); else { die("Line %d of the configuration file \"%s\":\n%s", config_error_line(&config_file_stuff), config_error_file(&config_file_stuff), config_error_text(&config_file_stuff));