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.
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.