From 986a54a56fc261d9196133ba0af0f15ad7915ee4 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 5 Apr 2009 14:48:24 +0200 Subject: [PATCH] xbps_removed_binary_pkg(): chdir after checking if pkg is installed not before. --HG-- extra : convert_revision : c06555f92939f37740b1677d842619eeb1f5d5ac --- lib/remove.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/remove.c b/lib/remove.c index f54bb4e1e5a..d3fc0d71ef0 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -221,16 +221,18 @@ xbps_remove_binary_pkg(const char *pkgname, bool update) assert(pkgname != NULL); + /* + * Check if pkg is installed before anything else. + */ + if (xbps_check_is_installed_pkgname(pkgname) == false) + return ENOENT; + if (strcmp(rootdir, "") == 0) rootdir = "/"; if (chdir(rootdir) == -1) return errno; - /* Check if pkg is installed */ - if (xbps_check_is_installed_pkgname(pkgname) == false) - return ENOENT; - buf = xbps_xasprintf("%s/%s/metadata/%s/REMOVE", rootdir, XBPS_META_PATH, pkgname); if (buf == NULL)