From 2c4e0124976724a7ae56bfee0ac4f7046c819ea8 Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 30 Jan 2006 15:59:17 +0000 Subject: [PATCH] Update fc-cat to handle subdir lists in global cache file. Another FcCacheReadString return value check. --- ChangeLog | 9 +++++++++ fc-cat/fc-cat.c | 10 ++++++++++ src/fccache.c | 11 +++++++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4755e7f..5057b59 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2006-01-30 Patrick Lam + * fc-cat/fc-cat.c (FcCacheGlobalFileReadAndPrint): + + Update fc-cat to handle subdir lists in global cache file. + + * src/fccache.c (FcGlobalCacheLoad): + + Another FcCacheReadString return value check. + 2006-01-30 Mike Fabian reviewed by: plam diff --git a/fc-cat/fc-cat.c b/fc-cat/fc-cat.c index 3b24302..a203d74 100644 --- a/fc-cat/fc-cat.c +++ b/fc-cat/fc-cat.c @@ -174,6 +174,7 @@ FcCacheGlobalFileReadAndPrint (FcFontSet * set, FcStrSet *dirs, char *cache_file int fd; char * current_arch_machine_name; char candidate_arch_machine_name[9+MACHINE_SIGNATURE_SIZE]; + char subdirName[FC_MAX_FILE_LEN + 1 + 12 + 1]; off_t current_arch_start = 0; if (!cache_file) @@ -202,6 +203,15 @@ FcCacheGlobalFileReadAndPrint (FcFontSet * set, FcStrSet *dirs, char *cache_file printf ("fc-cat: printing global cache contents for dir %s\n", name_buf); + do + { + if (!FcCacheReadString (fd, subdirName, + sizeof (subdirName)) || + !strlen (subdirName)) + break; + /* then don't do anything with subdirName. */ + } while (1); + if (!FcDirCacheConsume (fd, name_buf, set, 0)) goto bail1; diff --git a/src/fccache.c b/src/fccache.c index 5af247a..3dd7eae 100644 --- a/src/fccache.c +++ b/src/fccache.c @@ -240,7 +240,8 @@ FcGlobalCacheLoad (FcGlobalCache *cache, { off_t targ; - if (!FcCacheReadString (cache->fd, name_buf, sizeof (name_buf)) || !strlen(name_buf)) + if (!FcCacheReadString (cache->fd, name_buf, sizeof (name_buf)) || + !strlen(name_buf)) break; /* Directory must be older than the global cache file; also @@ -269,8 +270,14 @@ FcGlobalCacheLoad (FcGlobalCache *cache, d->offset = lseek (cache->fd, 0, SEEK_CUR); d->subdirs = FcStrSetCreate(); - while (strlen(FcCacheReadString (cache->fd, subdirName, sizeof (subdirName))) > 0) + do + { + if (!FcCacheReadString (cache->fd, subdirName, + sizeof (subdirName)) || + !strlen (subdirName)) + break; FcStrSetAdd (d->subdirs, (FcChar8 *)subdirName); + } while (1); if (read (cache->fd, &d->metadata, sizeof (FcCache)) != sizeof (FcCache)) goto bail1; -- 2.39.5