]> git.wh0rd.org - fontconfig.git/commitdiff
Avoid crashes if config files contain junk.
authorMike FABIAN <mfabian@suse.de>
Thu, 18 Oct 2007 12:44:28 +0000 (05:44 -0700)
committerKeith Packard <keithp@koto.keithp.com>
Thu, 18 Oct 2007 12:44:28 +0000 (05:44 -0700)
If ~/.fonts.conf contains:

  <edit mode="assign_replace" name="spacing">
     <int>mono</int>
       </edit>

fontconfig crashes:

    mfabian@magellan:~$ fc-match sans
        Fontconfig error: "~/.fonts.conf", line 46: "mono": not a valid
integer
    セグメンテーション違反です (core dumped)
        mfabian@magellan:~$

Of course the above is nonsense, “mono” is no valid integer indeed.

But I think nevertheless fontconfig should not crash in that case.

The problem was caused by partially truncated expression trees caused by
parse errors -- typechecking these walked the tree without verifying the
integrity of the structure. Of course, the whole tree will be discarded
shortly after being loaded as it contained an error.

src/fcxml.c

index 156599ca2fd5d8b5a94763664febc32920d7a826..3b08fea593eb46db055cdcaf03014a8b549d5604 100644 (file)
@@ -558,6 +558,10 @@ FcTypecheckExpr (FcConfigParse *parse, FcExpr *expr, FcType type)
     const FcObjectType *o;
     const FcConstant   *c;
     
+    /* If parsing the expression failed, some nodes may be NULL */
+    if (!expr)
+       return;
+
     switch (expr->op) {
     case FcOpInteger:
     case FcOpDouble: