Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/util.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-04 08:42:52 -0600
committerDan McGee <dan@archlinux.org>2011-02-04 08:42:55 -0600
commit7467fb9e763d9895044791eb0407e58d2793f377 (patch)
treebf82f0af2e946e5200ce1860fdb29d4594e7efa2 /lib/libalpm/util.c
parentf89277536612ff8e204cefcb6ff7cca7079d6bd5 (diff)
Ensure found files are actually files
We located files in a few places but didn't check if they were files or directories. Ensure they are actually files using stat() and S_ISREG(); this showed itself when trying to download to the directory name itself in FS#22645. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/util.c')
-rw-r--r--lib/libalpm/util.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index 82387b2f..a80a7327 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -608,12 +608,13 @@ char *_alpm_filecache_find(const char* filename)
char path[PATH_MAX];
char *retpath;
alpm_list_t *i;
+ struct stat buf;
/* Loop through the cache dirs until we find a matching file */
for(i = alpm_option_get_cachedirs(); i; i = alpm_list_next(i)) {
snprintf(path, PATH_MAX, "%s%s", (char*)alpm_list_getdata(i),
filename);
- if(access(path, R_OK) == 0) {
+ if(stat(path, &buf) == 0 && S_ISREG(buf.st_mode)) {
retpath = strdup(path);
_alpm_log(PM_LOG_DEBUG, "found cached pkg: %s\n", retpath);
return(retpath);