1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-12-22 15:58:50 -05:00

Fix opendir error condition checks

Thanks to Laszlo Papp <djszapi@archlinux.us> for the following catch:
  opendir(path)) == (DIR *)-1;
is maybe the result of misunderstanding the manpage. If an opendir() call
isn't successful it returns NULL rather than '(DIR *)-1'.

Noticed-by: Laszlo Papp <djszapi@archlinux.us>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dan McGee 2009-10-27 21:11:29 -05:00
parent fff6d9dc2e
commit 133a39e2bb
2 changed files with 4 additions and 2 deletions

View File

@ -404,7 +404,8 @@ int _alpm_rmrf(const char *path)
}
}
} else {
if((dirp = opendir(path)) == (DIR *)-1) {
dirp = opendir(path);
if(!dirp) {
return(1);
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {

View File

@ -174,7 +174,8 @@ int rmrf(const char *path)
return(1);
}
if((dirp = opendir(path)) == (DIR *)-1) {
dirp = opendir(path);
if(!dirp) {
return(1);
}
for(dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {