]> git.wh0rd.org Git - fontconfig.git/commitdiff
Deal correctly with changing FC_CACHE_MAGIC.
authorPatrick Lam <plam@MIT.EDU>
Thu, 16 Feb 2006 17:50:04 +0000 (17:50 +0000)
committerPatrick Lam <plam@MIT.EDU>
Thu, 16 Feb 2006 17:50:04 +0000 (17:50 +0000)
ChangeLog
src/fccache.c

index 7da4745527292f1c0c8a561b3fd9297f58ff50ce..220470af67996e7c1fa0a7dfd87885fa56e6d3e3 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-02-16  Patrick Lam  <plam@mit.edu>
+       * src/fccache.c (FcDirCacheHasCurrentArch):
+
+       Deal correctly with changing FC_CACHE_MAGIC.
+
 2006-02-16  Patrick Lam  <plam@mit.edu>
        * fc-cache/fc-cache.c (usage, scanDirs, main):
 
index fa7051628cef34d27d2455a6d42daea60fcf8753..6385d3ff672152e0e3c27e79eacba5233d6446b2 100644 (file)
@@ -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)