From 660acf8f2278df9276c9a1bff3533e9a74fd8c6b Mon Sep 17 00:00:00 2001 From: Patrick Lam Date: Mon, 6 Feb 2006 23:11:41 +0000 Subject: [PATCH] Don't loop infinitely on recursive symlinks. reviewed by: plam --- ChangeLog | 6 ++++++ fc-cache/fc-cache.c | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/ChangeLog b/ChangeLog index ec58f33..5bb6832 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2006-02-06 Takashi Iwai + reviewed by: plam + * fc-cache/fc-cache.c (scanDirs, main): + + Don't loop infinitely on recursive symlinks. + 2006-02-06 Takashi Iwai reviewed by: plam * src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheReadDir, diff --git a/fc-cache/fc-cache.c b/fc-cache/fc-cache.c index f93a085..c4cca32 100644 --- a/fc-cache/fc-cache.c +++ b/fc-cache/fc-cache.c @@ -93,6 +93,8 @@ usage (char *program) exit (1); } +static FcStrSet *processed_dirs; + static int nsubdirs (FcStrSet *set) { @@ -140,6 +142,12 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool continue; } + if (FcStrSetMember (processed_dirs, dir)) + { + if (verbose) + printf ("skipping, looped directory detected\n"); + continue; + } set = FcFontSetCreate (); if (!set) @@ -236,6 +244,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool ret++; continue; } + FcStrSetAdd (processed_dirs, dir); ret += scanDirs (sublist, config, program, force, verbose); } FcStrListDone (list); @@ -318,7 +327,16 @@ main (int argc, char **argv) } else list = FcConfigGetConfigDirs (config); + + if ((processed_dirs = FcStrSetCreate()) == NULL) { + fprintf(stderr, "Cannot malloc\n"); + return 1; + } + ret = scanDirs (list, config, argv[0], force, verbose); + + FcStrSetDestroy (processed_dirs); + /* * Now we need to sleep a second (or two, to be extra sure), to make * sure that timestamps for changes after this run of fc-cache are later -- 2.39.5