]> git.wh0rd.org Git - fontconfig.git/commitdiff
Avoid writing uninitialized structure pad bytes to cache files.
authorKeith Packard <keithp@neko.keithp.com>
Sat, 2 Dec 2006 21:04:05 +0000 (13:04 -0800)
committerKeith Packard <keithp@neko.keithp.com>
Sat, 2 Dec 2006 21:04:05 +0000 (13:04 -0800)
The union inside the FcValue structure contains pad bytes. Instead of
copying the whole structure to the cache block, copy only the initialized
fields to avoid writing whichever bytes serve as padding within the
structure.

src/fcpat.c

index bf34c2e2c4c1869f6c12303792a4f065e60e17e1..052874ffbbf5f4077fb6508250ea064af736282e 100644 (file)
@@ -1174,8 +1174,14 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
            head_serialized = vl_serialized;
        
        vl_serialized->next = NULL;
-       vl_serialized->value = vl->value;
+       vl_serialized->value.type = vl->value.type;
        switch (vl->value.type) {
+       case FcTypeInteger:
+           vl_serialized->value.u.i = vl->value.u.i;
+           break;
+       case FcTypeDouble:
+           vl_serialized->value.u.d = vl->value.u.d;
+           break;
        case FcTypeString:
            s_serialized = FcStrSerialize (serialize, vl->value.u.s);
            if (!s_serialized)
@@ -1184,6 +1190,12 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
                                                             s_serialized,
                                                             FcChar8);
            break;
+       case FcTypeBool:
+           vl_serialized->value.u.b = vl->value.u.b;
+           break;
+       case FcTypeMatrix:
+           /* can't happen */
+           break;
        case FcTypeCharSet:
            c_serialized = FcCharSetSerialize (serialize, vl->value.u.c);
            if (!c_serialized)
@@ -1192,6 +1204,9 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
                                                             c_serialized,
                                                             FcCharSet);
            break;
+       case FcTypeFTFace:
+           /* can't happen */
+           break;
        case FcTypeLangSet:
            l_serialized = FcLangSetSerialize (serialize, vl->value.u.l);
            if (!l_serialized)