From 8c0d692125018052fa228721f30f760dfb0c0adf Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Thu, 16 Feb 2006 17:50:04 +0000 Subject: [PATCH] Deal correctly with changing FC_CACHE_MAGIC. --- ChangeLog | 5 +++++ src/fccache.c | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/ChangeLog b/ChangeLog index 7da4745..220470a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2006-02-16 Patrick Lam + * src/fccache.c (FcDirCacheHasCurrentArch): + + Deal correctly with changing FC_CACHE_MAGIC. + 2006-02-16 Patrick Lam * fc-cache/fc-cache.c (usage, scanDirs, main): diff --git a/src/fccache.c b/src/fccache.c index fa70516..6385d3f 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -759,6 +759,7 @@ FcDirCacheHasCurrentArch (const FcChar8 *dir) int fd; off_t current_arch_start; char *current_arch_machine_name; + FcCache metadata; fd = FcDirCacheOpen (dir); if (fd < 0) @@ -766,6 +767,22 @@ FcDirCacheHasCurrentArch (const FcChar8 *dir) current_arch_machine_name = FcCacheMachineSignature(); current_arch_start = FcCacheSkipToArch(fd, current_arch_machine_name); + + if (current_arch_start >= 0) + { + if (read(fd, &metadata, sizeof(FcCache)) != sizeof(FcCache)) + { + close (fd); + return FcFalse; + } + + if (metadata.magic != FC_CACHE_MAGIC) + { + close (fd); + return FcFalse; + } + } + close (fd); if (current_arch_start < 0) -- 2.39.5