From: Andre Noll Date: Thu, 2 Jun 2016 15:37:26 +0000 (+0200) Subject: Abort if neither --database-dir nor --base-dir is given. X-Git-Url: http://git.tuebingen.mpg.de/?p=adu.git;a=commitdiff_plain;h=a830359f7afc8e98a2266ea023061efd6ad081a5;ds=sidebyside Abort if neither --database-dir nor --base-dir is given. If --database-dir is not given, adu concatenates the database root directory (which defaults to /var/lib/adu) with the value of the --base-dir argument. However, if --base-dir is not given either, base_dir_arg is NULL, and the concatenated string becomes the result is /var/lib/adu(null), at least on glibc. With this patch applied, adu handles this case more gracefully: it prints an error message and aborts early. --- diff --git a/adu.c b/adu.c index 37a0867..fe0caa5 100644 --- a/adu.c +++ b/adu.c @@ -296,9 +296,15 @@ static void get_database_dir_or_die(void) if (conf.database_dir_given) tmp = adu_strdup(conf.database_dir_arg); - else + else { + if (!conf.base_dir_arg) { + EMERG_LOG("fatal: neither database dir " + "nor base dir given\n"); + exit(EXIT_FAILURE); + } tmp = make_message("%s%s", conf.database_root_arg, conf.base_dir_arg); + } /* * As we change the cwd during database creation, database_dir * must be an absolute path.