[Fontconfig] robustness of the mmap cache branch
Patrick Lam
plam at MIT.EDU
Thu Sep 8 01:42:29 EST 2005
Matthias Clasen wrote:
> I think FcGlobalCacheLoad() needs some robustness love. Just
> copy any text file to ~/.fonts.cache-2 and watch FcGlobalCacheLoad()
> go in an infinite loop:
Actually, FcCacheSkipToArch was looping. I've fixed this by ensuring
that FcCacheSkipToArch always makes progress:
if (FcCacheReadString (fd, candidate_arch_machine_name_count,
sizeof (candidate_arch_machine_name_count)) == 0)
return -1;
if (!strlen(candidate_arch_machine_name_count))
return -1;
bs = strtol(candidate_arch_machine_name_count, &candidate_arch, 16);
+ if (!bs || bs < strlen (candidate_arch_machine_name_count))
+ return -1;
As you suggested, I also check the return values on read and lseek;
although they weren't the problem in this particular case, it's probably
still better to fix them.
Garbage .fonts.cache-2 files no longer trash fontconfig; it now
correctly regenerates the global cache file.
pat
More information about the Fontconfig
mailing list