Avoid writing uninitialized structure pad bytes to cache files.

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.
This commit is contained in:
Keith Packard 2006-12-02 13:04:05 -08:00
parent 64d7e303df
commit 2b77216ee2
1 changed files with 16 additions and 1 deletions

View File

@ -1174,8 +1174,14 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
head_serialized = vl_serialized; head_serialized = vl_serialized;
vl_serialized->next = NULL; vl_serialized->next = NULL;
vl_serialized->value = vl->value; vl_serialized->value.type = vl->value.type;
switch (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: case FcTypeString:
s_serialized = FcStrSerialize (serialize, vl->value.u.s); s_serialized = FcStrSerialize (serialize, vl->value.u.s);
if (!s_serialized) if (!s_serialized)
@ -1184,6 +1190,12 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
s_serialized, s_serialized,
FcChar8); FcChar8);
break; break;
case FcTypeBool:
vl_serialized->value.u.b = vl->value.u.b;
break;
case FcTypeMatrix:
/* can't happen */
break;
case FcTypeCharSet: case FcTypeCharSet:
c_serialized = FcCharSetSerialize (serialize, vl->value.u.c); c_serialized = FcCharSetSerialize (serialize, vl->value.u.c);
if (!c_serialized) if (!c_serialized)
@ -1192,6 +1204,9 @@ FcValueListSerialize (FcSerialize *serialize, const FcValueList *vl)
c_serialized, c_serialized,
FcCharSet); FcCharSet);
break; break;
case FcTypeFTFace:
/* can't happen */
break;
case FcTypeLangSet: case FcTypeLangSet:
l_serialized = FcLangSetSerialize (serialize, vl->value.u.l); l_serialized = FcLangSetSerialize (serialize, vl->value.u.l);
if (!l_serialized) if (!l_serialized)