diff options
author | Aaron Griffin <aaron@archlinux.org> | 2007-03-19 05:49:28 +0100 |
---|---|---|
committer | Aaron Griffin <aaron@archlinux.org> | 2007-03-19 05:49:28 +0100 |
commit | 22206d5beab9df816872a2f78280a4b35ecac34d (patch) | |
tree | e90bebebcbe7fa6c57c3309b324dba7d8fd3e0fb /lib | |
parent | bd55cf548c63958e6d4e8c15ccd5bed3972e0574 (diff) | |
download | pacman-22206d5beab9df816872a2f78280a4b35ecac34d.tar.gz pacman-22206d5beab9df816872a2f78280a4b35ecac34d.tar.xz |
Nagy Gabor <ngaba@petra.hos.u-szeged.hu>
* correct _alpm_rmrf usage with regard to symlinks and directories
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/util.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c index be9eeb31..2b3847ad 100644 --- a/lib/libalpm/util.c +++ b/lib/libalpm/util.c @@ -310,21 +310,20 @@ int _alpm_rmrf(const char *path) struct dirent *dp; DIR *dirp; char name[PATH_MAX]; - struct stat st; + struct stat st; - if(stat(path, &st) == 0) { - if(S_ISREG(st.st_mode)) { + if(lstat(path, &st) == 0) { + if(!S_ISDIR(st.st_mode)) { if(!unlink(path)) { return(0); } else { if(errno == ENOENT) { return(0); } else { - /* not a directory */ return(1); } } - } else if(S_ISDIR(st.st_mode)) { + } else { if((dirp = opendir(path)) == (DIR *)-1) { return(1); } |