mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Ensure d_type is not DT_UNKNOWN before relying on it
Fixes FS#23090, a rather serious problem where the user was completely unable to read the local database. Even if entry->d_type is available, the given filesystem providing it may not fill the contents, in which case we should fall back to a stat() as we did before. In this case, the filesystem was XFS but there may be others. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
09ce8b446c
commit
b12be99c89
@ -351,18 +351,22 @@ static int checkdbdir(pmdb_t *db)
|
|||||||
static int is_dir(const char *path, struct dirent *entry)
|
static int is_dir(const char *path, struct dirent *entry)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
#ifdef HAVE_STRUCT_DIRENT_D_TYPE
|
||||||
return(entry->d_type == DT_DIR);
|
if(entry->d_type != DT_UNKNOWN) {
|
||||||
#else
|
return(entry->d_type == DT_DIR);
|
||||||
char buffer[PATH_MAX];
|
}
|
||||||
snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
|
#endif
|
||||||
|
{
|
||||||
|
char buffer[PATH_MAX];
|
||||||
|
struct stat sbuf;
|
||||||
|
|
||||||
struct stat sbuf;
|
snprintf(buffer, PATH_MAX, "%s/%s", path, entry->d_name);
|
||||||
if (!stat(buffer, &sbuf)) {
|
|
||||||
return(S_ISDIR(sbuf.st_mode));
|
if (!stat(buffer, &sbuf)) {
|
||||||
|
return(S_ISDIR(sbuf.st_mode));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return(0);
|
return(0);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int local_db_populate(pmdb_t *db)
|
static int local_db_populate(pmdb_t *db)
|
||||||
@ -462,7 +466,7 @@ static int local_db_populate(pmdb_t *db)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* add to the collection */
|
/* add to the collection */
|
||||||
_alpm_log(PM_LOG_FUNCTION, "adding '%s' to package cache for db '%s'\n",
|
_alpm_log(PM_LOG_DEBUG, "adding '%s' to package cache for db '%s'\n",
|
||||||
pkg->name, db->treename);
|
pkg->name, db->treename);
|
||||||
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
db->pkgcache = _alpm_pkghash_add(db->pkgcache, pkg);
|
||||||
count++;
|
count++;
|
||||||
|
Loading…
Reference in New Issue
Block a user