FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 08-11-2012, 09:35 PM
Andrew Gregory
 
Default query_fileowner: remove assumption that root is "/"

Returning "/" from mdirname removes it as a special case which allows us to
test it like any other directory. This corrects a false positive when querying
a file in / and root is not set to /.

Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
---
src/pacman/query.c | 31 ++++++-------------------------
src/pacman/util.c | 5 +++++
2 files changed, 11 insertions(+), 25 deletions(-)

diff --git a/src/pacman/query.c b/src/pacman/query.c
index 11876d8..b1e51a6 100644
--- a/src/pacman/query.c
+++ b/src/pacman/query.c
@@ -173,21 +173,12 @@ static int query_fileowner(alpm_list_t *targets)

bname = mbasename(filename);
dname = mdirname(filename);
- /* for files in '/', there is no directory name to match */
- if(strcmp(dname, "") == 0) {
- rpath = NULL;
- } else {
- rpath = realpath(dname, NULL);
+ rpath = realpath(dname, NULL);

- if(!rpath) {
- pm_printf(ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s
"),
- filename, strerror(errno));
- free(filename);
- free(dname);
- free(rpath);
- ret++;
- continue;
- }
+ if(!dname || !rpath) {
+ pm_printf(ALPM_LOG_ERROR, _("cannot determine real path for '%s': %s
"),
+ filename, strerror(errno));
+ goto targcleanup;
}
free(dname);

@@ -206,21 +197,11 @@ static int query_fileowner(alpm_list_t *targets)
continue;
}

- /* for files in '/', there is no directory name to match */
- if(!rpath) {
- if(strcmp(pkgfile, bname) == 0) {
- print_query_fileowner(filename, info);
- found = 1;
- break;
- }
- continue;
- }
-
+ /* concatenate our file and the root path */
if(rootlen + 1 + strlen(pkgfile) > PATH_MAX) {
pm_printf(ALPM_LOG_ERROR, _("path too long: %s%s
"), path, pkgfile);
continue;
}
- /* concatenate our file and the root path */
strcpy(path + rootlen, pkgfile);

pdname = mdirname(path);
diff --git a/src/pacman/util.c b/src/pacman/util.c
index 7f7f6a7..2d1b762 100644
--- a/src/pacman/util.c
+++ b/src/pacman/util.c
@@ -244,9 +244,14 @@ char *mdirname(const char *path)

if(last != NULL) {
/* we found a '/', so terminate our string */
+ if(last == ret) {
+ /* return "/" for root */
+ last++;
+ }
*last = '';
return ret;
}
+
/* no slash found */
free(ret);
return strdup(".");
--
1.7.11.4
 

Thread Tools




All times are GMT. The time now is 11:20 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org