3 Fix arbitrary code execution with embedded fonts (CVE-2008-1693).
5 --- xpdf/Object.h.orig 2007-02-27 22:05:52.000000000 +0000
7 @@ -68,17 +68,18 @@ enum ObjType {
8 //------------------------------------------------------------------------
11 -#define initObj(t) ++numAlloc[type = t]
12 +#define initObj(t) zeroUnion(); ++numAlloc[type = t]
14 -#define initObj(t) type = t
15 +#define initObj(t) zeroUnion(); type = t
21 + // attempt to clear the anonymous union
22 + void zeroUnion() { this->name = NULL; }
23 // Default constructor.
26 + type(objNone) { zeroUnion(); }
28 // Initialize an object.
29 Object *initBool(GBool boolnA)
30 @@ -220,16 +221,16 @@ private:
33 inline int Object::arrayGetLength()
34 - { return array->getLength(); }
35 + { if (type != objArray) return 0; return array->getLength(); }
37 inline void Object::arrayAdd(Object *elem)
38 - { array->add(elem); }
39 + { if (type == objArray) array->add(elem); }
41 inline Object *Object::arrayGet(int i, Object *obj)
42 - { return array->get(i, obj); }
43 + { if (type != objArray) return obj->initNull(); return array->get(i, obj); }
45 inline Object *Object::arrayGetNF(int i, Object *obj)
46 - { return array->getNF(i, obj); }
47 + { if (type != objArray) return obj->initNull(); return array->getNF(i, obj); }
49 //------------------------------------------------------------------------
51 @@ -238,31 +239,31 @@ inline Object *Object::arrayGetNF(int i,
54 inline int Object::dictGetLength()
55 - { return dict->getLength(); }
56 + { if (type != objDict) return 0; return dict->getLength(); }
58 inline void Object::dictAdd(char *key, Object *val)
59 - { dict->add(key, val); }
60 + { if (type == objDict) dict->add(key, val); }
62 inline GBool Object::dictIs(char *dictType)
63 - { return dict->is(dictType); }
64 + { return (type == objDict) && dict->is(dictType); }
66 inline GBool Object::isDict(char *dictType)
67 { return type == objDict && dictIs(dictType); }
69 inline Object *Object::dictLookup(char *key, Object *obj)
70 - { return dict->lookup(key, obj); }
71 + { if (type != objDict) return obj->initNull(); return dict->lookup(key, obj); }
73 inline Object *Object::dictLookupNF(char *key, Object *obj)
74 - { return dict->lookupNF(key, obj); }
75 + { if (type != objDict) return obj->initNull(); return dict->lookupNF(key, obj); }
77 inline char *Object::dictGetKey(int i)
78 - { return dict->getKey(i); }
79 + { if (type != objDict) return NULL; return dict->getKey(i); }
81 inline Object *Object::dictGetVal(int i, Object *obj)
82 - { return dict->getVal(i, obj); }
83 + { if (type != objDict) return obj->initNull(); return dict->getVal(i, obj); }
85 inline Object *Object::dictGetValNF(int i, Object *obj)
86 - { return dict->getValNF(i, obj); }
87 + { if (type != objDict) return obj->initNull(); return dict->getValNF(i, obj); }
89 //------------------------------------------------------------------------
91 @@ -271,33 +272,33 @@ inline Object *Object::dictGetValNF(int
94 inline GBool Object::streamIs(char *dictType)
95 - { return stream->getDict()->is(dictType); }
96 + { return (type == objStream) && stream->getDict()->is(dictType); }
98 inline GBool Object::isStream(char *dictType)
99 - { return type == objStream && streamIs(dictType); }
100 + { return (type == objStream) && streamIs(dictType); }
102 inline void Object::streamReset()
103 - { stream->reset(); }
104 + { if (type == objStream) stream->reset(); }
106 inline void Object::streamClose()
107 - { stream->close(); }
108 + { if (type == objStream) stream->close(); }
110 inline int Object::streamGetChar()
111 - { return stream->getChar(); }
112 + { if (type != objStream) return EOF; return stream->getChar(); }
114 inline int Object::streamLookChar()
115 - { return stream->lookChar(); }
116 + { if (type != objStream) return EOF; return stream->lookChar(); }
118 inline char *Object::streamGetLine(char *buf, int size)
119 - { return stream->getLine(buf, size); }
120 + { if (type != objStream) return NULL; return stream->getLine(buf, size); }
122 inline Guint Object::streamGetPos()
123 - { return stream->getPos(); }
124 + { if (type != objStream) return 0; return stream->getPos(); }
126 inline void Object::streamSetPos(Guint pos, int dir)
127 - { stream->setPos(pos, dir); }
128 + { if (type == objStream) stream->setPos(pos, dir); }
130 inline Dict *Object::streamGetDict()
131 - { return stream->getDict(); }
132 + { if (type != objStream) return NULL; return stream->getDict(); }