]> git.wh0rd.org - fontconfig.git/commitdiff
Don't loop infinitely on recursive symlinks.
authorPatrick Lam <plam@MIT.EDU>
Mon, 6 Feb 2006 23:11:41 +0000 (23:11 +0000)
committerPatrick Lam <plam@MIT.EDU>
Mon, 6 Feb 2006 23:11:41 +0000 (23:11 +0000)
reviewed by: plam

ChangeLog
fc-cache/fc-cache.c

index ec58f3366f653eabbc206dd08eee86d8ef893861..5bb68329295c1bf2317574eba4fc4c87bb7d4387 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2006-02-06  Takashi Iwai  <tiwai@suse.de>
+       reviewed by: plam
+       * fc-cache/fc-cache.c (scanDirs, main):
+
+       Don't loop infinitely on recursive symlinks.
+
 2006-02-06  Takashi Iwai  <tiwai@suse.de>
        reviewed by: plam
        * src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheReadDir,
index f93a0856e6d7d6335cec52b22364440c946a620a..c4cca3284a65115995177b2aa6f4e04cc509fa7e 100644 (file)
@@ -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