From 6bf2380478f825a6135527133a03869e0ae18742 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 3 Oct 2005 19:51:11 +0000 Subject: [PATCH] Ensure that a directory cache has the appropriate section before reporting that it is valid (reported by Matthias Clasen). --- ChangeLog | 6 ++++++ src/fccache.c | 15 +++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/ChangeLog b/ChangeLog index 318d26a..d85f2b2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2005-10-03 Patrick Lam + * 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 reviewed by: plam diff --git a/src/fccache.c b/src/fccache.c index d001e2b..7ff9fc6 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -522,6 +522,9 @@ FcDirCacheValid (const FcChar8 *dir) { FcChar8 *cache_file = FcStrPlus (dir, (FcChar8 *) "/" FC_DIR_CACHE_FILE); 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) { @@ -533,6 +536,18 @@ FcDirCacheValid (const FcChar8 *dir) FcStrFree (cache_file); 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); /* * If the directory has been modified more recently than -- 2.39.5