From 8028a1124abd585e5570cce95e8901eee15237be Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Tue, 5 Dec 2006 06:55:52 +0000 Subject: Added dbpath validation --- src/pacman/pacman.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 42cd2f85..3e6854c5 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -26,6 +26,8 @@ #include #include #include +#include +#include #include #include #include @@ -33,7 +35,6 @@ #include #elif defined(__OpenBSD__) || defined(__APPLE__) #include -#include #elif defined(CYGWIN) #include /* basename */ #else @@ -279,6 +280,7 @@ static int parseargs(int argc, char *argv[]) {0, 0, 0, 0} }; char root[PATH_MAX]; + struct stat st = {0}; while((opt = getopt_long(argc, argv, "ARUFQSTDYr:b:vkhscVfmnoldepiuwyg", opts, &option_index))) { if(opt < 0) { @@ -323,6 +325,10 @@ static int parseargs(int argc, char *argv[]) config->op_d_vertest = 1; break; case 'b': + if(stat(optarg, &st) == -1 || !S_ISDIR(st.st_mode)) { + pm_fprintf(stderr, NL, _("error: '%s' is not a valid db path\n"), optarg); + exit(1); + } alpm_option_set_dbpath(optarg); config->dbpath = alpm_option_get_dbpath(optarg); break; -- cgit v1.2.3-54-g00ecf