summaryrefslogtreecommitdiff
path: root/libwpd/libwpd.corruptedprefix.patch
blob: 1fa051f49eb85ca3fb4d7784d739084b020137a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
--- misc/libwpd-0.9.1/src/lib/WP6PrefixDataPacket.cpp
+++ misc/build/libwpd-0.9.1/src/lib/WP6PrefixDataPacket.cpp
@@ -46,45 +46,67 @@ WP6PrefixDataPacket::WP6PrefixDataPacket(WPXInputStream * /* input */, WPXEncryp
 }

 WP6PrefixDataPacket * WP6PrefixDataPacket::constructPrefixDataPacket(WPXInputStream * input, WPXEncryption *encryption, WP6PrefixIndice *prefixIndice)
-{
-	switch (prefixIndice->getType())
+{
+	WP6PrefixDataPacket *tmpPacket = 0;
+	try
+	{
+		switch (prefixIndice->getType())
+		{
+		case WP6_INDEX_HEADER_INITIAL_FONT:
+			tmpPacket = new WP6DefaultInitialFontPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_GENERAL_WORDPERFECT_TEXT:
+			tmpPacket = new WP6GeneralTextPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_DESIRED_FONT_DESCRIPTOR_POOL:
+			tmpPacket = new WP6FontDescriptorPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_FILL_STYLE:
+			tmpPacket = new WP6FillStylePacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY:
+			tmpPacket = new WP6ExtendedDocumentSummaryPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_OUTLINE_STYLE:
+			tmpPacket = new WP6OutlineStylePacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_GRAPHICS_FILENAME:
+			tmpPacket = new WP6GraphicsFilenamePacket(input, encryption, prefixIndice->getID(), prefixIndice->getFlags(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_GRAPHICS_CACHED_FILE_DATA:
+			tmpPacket = new WP6GraphicsCachedFileDataPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_GRAPHICS_BOX_STYLE:
+			tmpPacket = new WP6GraphicsBoxStylePacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_TABLE_STYLE:
+			tmpPacket = new WP6TableStylePacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		case WP6_INDEX_HEADER_COMMENT_ANNOTATION:
+			tmpPacket = new WP6CommentAnnotationPacket(input, encryption, prefixIndice->getID(),
+					prefixIndice->getDataOffset(), prefixIndice->getDataSize());
+			break;
+		default:
+			break;;
+		}
+	}
+	catch (FileException)
 	{
-	case WP6_INDEX_HEADER_INITIAL_FONT:
-		return new WP6DefaultInitialFontPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_GENERAL_WORDPERFECT_TEXT:
-		return new WP6GeneralTextPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_DESIRED_FONT_DESCRIPTOR_POOL:
-		return new WP6FontDescriptorPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_FILL_STYLE:
-		return new WP6FillStylePacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_EXTENDED_DOCUMENT_SUMMARY:
-		return new WP6ExtendedDocumentSummaryPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_OUTLINE_STYLE:
-		return new WP6OutlineStylePacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_GRAPHICS_FILENAME:
-		return new WP6GraphicsFilenamePacket(input, encryption, prefixIndice->getID(), prefixIndice->getFlags(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_GRAPHICS_CACHED_FILE_DATA:
-		return new WP6GraphicsCachedFileDataPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_GRAPHICS_BOX_STYLE:
-		return new WP6GraphicsBoxStylePacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_TABLE_STYLE:
-		return new WP6TableStylePacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	case WP6_INDEX_HEADER_COMMENT_ANNOTATION:
-		return new WP6CommentAnnotationPacket(input, encryption, prefixIndice->getID(),
-				prefixIndice->getDataOffset(), prefixIndice->getDataSize());
-	default:
-		return 0;
+		if (tmpPacket)
+			delete tmpPacket;
+		tmpPacket = 0;
 	}
+	return tmpPacket;
 }

 void WP6PrefixDataPacket::_read(WPXInputStream *input, WPXEncryption *encryption, uint32_t dataOffset, uint32_t dataSize)