From 204bf1d1461e2c0ec2836681c6bcf16a178f73a7 Mon Sep 17 00:00:00 2001 From: Laurent Vivier Date: Sun, 1 Jun 2014 23:52:03 +0200 Subject: [PATCH] emile: add more checks when reading emile.conf --- tools/emile.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tools/emile.c b/tools/emile.c index 597d847..6838cbb 100644 --- a/tools/emile.c +++ b/tools/emile.c @@ -990,13 +990,19 @@ int main(int argc, char **argv) } ret = config_get_property(config, "first_level", property); - if (ret == -1) + if (ret == -1) { + fprintf(stderr, + "ERROR: missing first_level in config file\n"); return 2; + } first_path = strdup(property); ret = config_get_property(config, "second_level", property); - if (ret == -1) + if (ret == -1) { + fprintf(stderr, + "ERROR: missing second_level in config file\n"); return 2; + } second_path = strdup(property); fd = open(first_path, O_RDONLY); @@ -1024,6 +1030,11 @@ int main(int argc, char **argv) /* set configuration in second level */ fd = open(second_path, O_RDWR); + if (fd == -1) { + fprintf(stderr, + "ERROR: cannot open \"%s\".\n", second_path); + return 30; + } emile_second_set_configuration(fd, configuration); close(fd);