aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2011-03-01 06:11:54 +0000
committerMike Frysinger <vapier@gentoo.org>2011-03-01 06:11:54 +0000
commit819c10b9e8fe1316e96a0d5c023db63f29d05001 (patch)
tree5767154c4942de6ea0467373f090eca912c84253 /qfile.c
parentdont bother checking for hidden dirs again since filter_hidden did this already (diff)
downloadportage-utils-819c10b9e8fe1316e96a0d5c023db63f29d05001.tar.gz
portage-utils-819c10b9e8fe1316e96a0d5c023db63f29d05001.tar.bz2
portage-utils-819c10b9e8fe1316e96a0d5c023db63f29d05001.zip
make sure ROOT works properly
Diffstat (limited to 'qfile.c')
-rw-r--r--qfile.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/qfile.c b/qfile.c
index 2a25f27..2c3f674 100644
--- a/qfile.c
+++ b/qfile.c
@@ -1,7 +1,7 @@
/*
* Copyright 2005-2010 Gentoo Foundation
* Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qfile.c,v 1.55 2011/02/21 07:33:21 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qfile.c,v 1.56 2011/03/01 06:11:54 vapier Exp $
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
* Copyright 2005-2010 Mike Frysinger - <vapier@gentoo.org>
@@ -34,7 +34,7 @@ static const char * const qfile_opts_help[] = {
"Display installed packages with slots",
COMMON_OPTS_HELP
};
-static const char qfile_rcsid[] = "$Id: qfile.c,v 1.55 2011/02/21 07:33:21 vapier Exp $";
+static const char qfile_rcsid[] = "$Id: qfile.c,v 1.56 2011/03/01 06:11:54 vapier Exp $";
#define qfile_usage(ret) usage(ret, QFILE_FLAGS, qfile_long_opts, qfile_opts_help, lookup_applet_idx("qfile"))
#define qfile_is_prefix(path, prefix, prefix_length) \
@@ -488,7 +488,7 @@ int qfile_main(int argc, char **argv)
char *p;
short search_orphans = 0;
short assume_root_prefix = 0;
- char *root_prefix = NULL;
+ char *root_prefix;
char *exclude_pkg_arg = NULL;
qfile_args_t *qfile_args = NULL;
int qargc = 0;
@@ -497,7 +497,7 @@ int qfile_main(int argc, char **argv)
FILE *args_file = NULL;
int max_args = QFILE_DEFAULT_MAX_ARGS;
size_t buflen;
- char *buf = NULL;
+ char *buf;
DBG("argc=%d argv[0]=%s argv[1]=%s",
argc, argv[0], argc > 1 ? argv[1] : "NULL?");
@@ -552,8 +552,10 @@ int qfile_main(int argc, char **argv)
if ((args_file == NULL) && (max_args != QFILE_DEFAULT_MAX_ARGS))
warn("--max-args is only used when reading arguments from a file (with -f)");
- xchdir(portroot);
- xchdir(portvdb);
+ xasprintf(&buf, "%s/%s", portroot, portvdb);
+ xchdir(buf);
+ free(buf);
+ buf = NULL;
/* Get a copy of $ROOT, with no trailing slash
* (this one is just for qfile(...) output)
@@ -655,8 +657,7 @@ exit:
free(qfile_args);
}
- if (root_prefix != NULL)
- free(root_prefix);
+ free(root_prefix);
return (found ? EXIT_SUCCESS : EXIT_FAILURE);
}