Ensure that a directory cache has the appropriate section before reporting

that it is valid (reported by Matthias Clasen).
This commit is contained in:
Patrick Lam 2005-10-03 19:51:11 +00:00
parent bc5784ff00
commit 6bf2380478
2 changed files with 21 additions and 0 deletions

View File

@ -1,3 +1,9 @@
2005-10-03 Patrick Lam <plam@mit.edu>
* src/fccache.c (FcDirCacheValid):
Ensure that a directory cache has the appropriate section
before reporting that it is valid (reported by Matthias Clasen).
2005-09-29 Mathias Hasselmann <mathias.hasselmann@gmx.de> 2005-09-29 Mathias Hasselmann <mathias.hasselmann@gmx.de>
reviewed by: plam reviewed by: plam

View File

@ -522,6 +522,9 @@ FcDirCacheValid (const FcChar8 *dir)
{ {
FcChar8 *cache_file = FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE); FcChar8 *cache_file = FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE);
struct stat file_stat, dir_stat; struct stat file_stat, dir_stat;
int fd;
off_t current_arch_start;
char *current_arch_machine_name;
if (stat ((char *) dir, &dir_stat) < 0) if (stat ((char *) dir, &dir_stat) < 0)
{ {
@ -533,6 +536,18 @@ FcDirCacheValid (const FcChar8 *dir)
FcStrFree (cache_file); FcStrFree (cache_file);
return FcFalse; return FcFalse;
} }
current_arch_machine_name = FcCacheMachineSignature();
fd = open(cache_file, O_RDONLY);
if (fd == -1)
return FcFalse;
current_arch_start = FcCacheSkipToArch(fd, current_arch_machine_name);
close (fd);
if (current_arch_start < 0)
return FcFalse;
FcStrFree (cache_file); FcStrFree (cache_file);
/* /*
* If the directory has been modified more recently than * If the directory has been modified more recently than