Commit 36567121 authored by Guillem Jover's avatar Guillem Jover

dpkg-query: Refactor pkg_infodb_check_filetype() from control_path()

parent 8e4bad69
......@@ -580,6 +580,17 @@ pkg_infodb_is_internal(const char *filetype)
return false;
}
static void
pkg_infodb_check_filetype(const char *filetype)
{
const char *c;
/* Validate control file name for sanity. */
for (c = "/."; *c; c++)
if (strchr(filetype, *c))
badusage(_("control file contains %c"), *c);
}
static void
pkg_infodb_print_filename(const char *filename, const char *filetype)
{
......@@ -621,14 +632,8 @@ control_path(const char *const *argv)
if (control_file && *argv)
badusage(_("--%s takes at most two arguments"), cipaction->olong);
/* Validate control file name for sanity. */
if (control_file) {
const char *c;
for (c = "/."; *c; c++)
if (strchr(control_file, *c))
badusage(_("control file contains %c"), *c);
}
if (control_file)
pkg_infodb_check_filetype(control_file);
modstatdb_open(msdbrw_readonly);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment