Re: Yet another easy to reproduce crash in fontconfig

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Mike FABIAN <mfabian@xxxxxxx> さんは書きました:

> mfabian@magellan:~$ sudo rm /var/cache/fontconfig/*cache*
> mfabian@magellan:~$ rm .fonts.cache-2 
> mfabian@magellan:~$ fc-match sans
> arial.ttf: "Arial" "Regular"
> mfabian@magellan:~$ touch .fonts.conf
> mfabian@magellan:~$ fc-match sans
> セグメンテーション違反です (core dumped)
> mfabian@magellan:~$
> (gdb) bt
> #0  0x00002aaaab12c420 in strlen () from /lib64/
> #1  0x00002aaaaabd7075 in FcGlobalCacheReadDir () from /usr/lib64/

The attached patch seems to fix the problem for me.

Without that patch, directories which are subdirectories of
directories listed in the config files (/etc/fonts/fonts.conf etc)
were added too late to the list of font directories in "FcConfig
*config". For example, when FcDirScanConfig() was called with the
argument "/usr/share/fonts/bdf" the list of font directories in
config->fontDirs->strs still contained only the higher level
directory "/usr/share/fonts" because only that was listed in the
config files, not the "bdf" subdirectory.

FcDirScanConfig() then calls FcGlobalCacheReadDir() before
adding the subdirectory to the list, FcGlobalCacheReadDir()
calls FcConfigNormalizeFontDir(dir) which returns 0 because the directory
is not yet in the list and then it crashes in strlen(dir) of course.

To fix this, I moved the call to FcConfigAddFontDir (config, dir)
upwards in FcDirScanConfig() to add the directory *before*
FcGlobalCacheReadDir() is called.

diff -ru fontconfig- fontconfig-
--- fontconfig-	2006-01-16 12:47:55.000000000 +0100
+++ fontconfig-	2006-01-18 15:12:06.000000000 +0100
@@ -130,6 +130,8 @@
     if (config && !FcConfigAcceptFilename (config, dir))
 	return FcTrue;
+    FcConfigAddFontDir (config, dir);
     if (!force)
@@ -165,7 +167,6 @@
 	return FcFalse;
-    FcConfigAddFontDir (config, dir);
     tmpSet = FcFontSetCreate();
     if (!tmpSet)
Mike FABIAN   <mfabian@xxxxxxx>
Fontconfig mailing list

[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux