From 22206d5beab9df816872a2f78280a4b35ecac34d Mon Sep 17 00:00:00 2001 From: Aaron Griffin Date: Mon, 19 Mar 2007 04:49:28 +0000 Subject: Nagy Gabor * correct _alpm_rmrf usage with regard to symlinks and directories --- lib/libalpm/util.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'lib') 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); } -- cgit v1.2.3-70-g09d2