From 161f97ce9766f9093a7c3c070c0bf006d97d7676 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sun, 5 Apr 2009 12:41:40 +0200 Subject: [PATCH] Fix chdir() when rootdir it's an empty string. --HG-- extra : convert_revision : bb7847fc538401d8c585bcb75114956f879077d3 --- lib/remove.c | 3 +++ lib/unpack.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/lib/remove.c b/lib/remove.c index f971d1af45c..8219caa37d8 100644 --- a/lib/remove.c +++ b/lib/remove.c @@ -219,6 +219,9 @@ xbps_remove_binary_pkg(const char *pkgname, bool update) assert(pkgname != NULL); + if (strcmp(rootdir, "") == 0) + rootdir = "/"; + if (rootdir) { if (chdir(rootdir) == -1) return errno; diff --git a/lib/unpack.c b/lib/unpack.c index 66e4f0f697b..92ebbb69cea 100644 --- a/lib/unpack.c +++ b/lib/unpack.c @@ -140,6 +140,9 @@ unpack_archive_fini(struct archive *ar, prop_dictionary_t pkg) rootdir = xbps_get_rootdir(); flags = xbps_get_flags(); + if (strcmp(rootdir, "") == 0) + rootdir = "/"; + if (rootdir) { if (chdir(rootdir) == -1) return errno;