Don't loop infinitely on recursive symlinks.

reviewed by: plam
This commit is contained in:
Patrick Lam 2006-02-06 23:11:41 +00:00
parent fff5a5af30
commit 660acf8f22
2 changed files with 24 additions and 0 deletions

View File

@ -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> 2006-02-06 Takashi Iwai <tiwai@suse.de>
reviewed by: plam reviewed by: plam
* src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheReadDir, * src/fccache.c (FcGlobalCacheLoad, FcGlobalCacheReadDir,

View File

@ -93,6 +93,8 @@ usage (char *program)
exit (1); exit (1);
} }
static FcStrSet *processed_dirs;
static int static int
nsubdirs (FcStrSet *set) nsubdirs (FcStrSet *set)
{ {
@ -140,6 +142,12 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
continue; continue;
} }
if (FcStrSetMember (processed_dirs, dir))
{
if (verbose)
printf ("skipping, looped directory detected\n");
continue;
}
set = FcFontSetCreate (); set = FcFontSetCreate ();
if (!set) if (!set)
@ -236,6 +244,7 @@ scanDirs (FcStrList *list, FcConfig *config, char *program, FcBool force, FcBool
ret++; ret++;
continue; continue;
} }
FcStrSetAdd (processed_dirs, dir);
ret += scanDirs (sublist, config, program, force, verbose); ret += scanDirs (sublist, config, program, force, verbose);
} }
FcStrListDone (list); FcStrListDone (list);
@ -318,7 +327,16 @@ main (int argc, char **argv)
} }
else else
list = FcConfigGetConfigDirs (config); list = FcConfigGetConfigDirs (config);
if ((processed_dirs = FcStrSetCreate()) == NULL) {
fprintf(stderr, "Cannot malloc\n");
return 1;
}
ret = scanDirs (list, config, argv[0], force, verbose); 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 * 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 * sure that timestamps for changes after this run of fc-cache are later