]> git.wh0rd.org Git - fontconfig.git/commitdiff
Segfault scanning non-font files. Disallow scan edit of user vars. (#8767)
authorKeith Packard <keithp@neko.keithp.com>
Sat, 2 Dec 2006 21:57:45 +0000 (13:57 -0800)
committerKeith Packard <keithp@neko.keithp.com>
Sat, 2 Dec 2006 21:57:45 +0000 (13:57 -0800)
Missing NULL font check before attempting to edit scanned pattern.
Also, <match target="scan"> rules are now checked to ensure all
edited variables are in the predefined set; otherwise, the resulting
cache files will not be stable.

src/fcdir.c
src/fcint.h
src/fcxml.c

index d08299269f0f85bcf937c2d224cab9f4c91c3f3e..e9e9d197c57a444801680afe5ce1c93213fe8707 100644 (file)
@@ -65,7 +65,7 @@ FcFileScanFontConfig (FcFontSet               *set,
        /*
         * Edit pattern with user-defined rules
         */
-       if (config && !FcConfigSubstituteWithPat (config, font, NULL, FcMatchScan))
+       if (font && config && !FcConfigSubstituteWithPat (config, font, NULL, FcMatchScan))
        {
            FcPatternDestroy (font);
            font = NULL;
index 60563cb56a046e3be37f85d1b0984a0d4c02fbb5..4ab4a74906a77fb6087ce73ee56af314018c17d4 100644 (file)
@@ -865,6 +865,7 @@ FcListPatternMatchAny (const FcPattern *p,
 #define FC_EMBOLDEN_OBJECT     38
 #define FC_EMBEDDED_BITMAP_OBJECT      39
 #define FC_DECORATIVE_OBJECT   40
+#define FC_MAX_BASE_OBJECT     FC_DECORATIVE_OBJECT
 
 FcPrivate FcBool
 FcNameBool (const FcChar8 *v, FcBool *result);
index a9453ebc0b01b31187320bcd5b08057836affe86..156599ca2fd5d8b5a94763664febc32920d7a826 100644 (file)
@@ -1845,6 +1845,12 @@ FcParseMatch (FcConfigParse *parse)
            vstack->u.edit->next = edit;
            edit = vstack->u.edit;
            vstack->tag = FcVStackNone;
+           if (kind == FcMatchScan && edit->object > FC_MAX_BASE_OBJECT)
+           {
+               FcConfigMessage (parse, FcSevereError, 
+                                "<match target=\"scan\"> cannot edit user-defined object \"%s\"",
+                                FcObjectName(edit->object));
+           }
            break;
        default:
            FcConfigMessage (parse, FcSevereWarning, "invalid match element");