summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/dload.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2011-02-04 15:42:52 +0100
committerDan McGee <dan@archlinux.org>2011-02-04 15:42:55 +0100
commit7467fb9e763d9895044791eb0407e58d2793f377 (patch)
treebf82f0af2e946e5200ce1860fdb29d4594e7efa2 /lib/libalpm/dload.c
parentf89277536612ff8e204cefcb6ff7cca7079d6bd5 (diff)
downloadpacman-7467fb9e763d9895044791eb0407e58d2793f377.tar.gz
pacman-7467fb9e763d9895044791eb0407e58d2793f377.tar.xz
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/dload.c')
-rw-r--r--lib/libalpm/dload.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/libalpm/dload.c b/lib/libalpm/dload.c
index cb6d000c..c856e96c 100644
--- a/lib/libalpm/dload.c
+++ b/lib/libalpm/dload.c
@@ -128,13 +128,13 @@ static int download_internal(const char *url, const char *localpath,
destfile = get_destfile(localpath, filename);
tempfile = get_tempfile(localpath, filename);
- if(stat(tempfile, &st) == 0 && st.st_size > 0) {
+ if(stat(tempfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
_alpm_log(PM_LOG_DEBUG, "tempfile found, attempting continuation\n");
local_time = fileurl->last_modified = st.st_mtime;
local_size = fileurl->offset = (off_t)st.st_size;
dl_thisfile = st.st_size;
localf = fopen(tempfile, "ab");
- } else if(!force && stat(destfile, &st) == 0 && st.st_size > 0) {
+ } else if(!force && stat(destfile, &st) == 0 && S_ISREG(st.st_mode) && st.st_size > 0) {
_alpm_log(PM_LOG_DEBUG, "destfile found, using mtime only\n");
local_time = fileurl->last_modified = st.st_mtime;
local_size = /* no fu->off here */ (off_t)st.st_size;