File ImageMagick-CVE-2017-12428,12431,11534.patch of Package ImageMagick (Revision ede7a536328eec17bacb42c62585ca00)
Currently displaying revision ede7a536328eec17bacb42c62585ca00 , Show latest
153
1
From f37d26336bf13737db45e556c25fc098f8a8b277 Mon Sep 17 00:00:00 2001
2
From: Cristy <urban-warrior@imagemagick.org>
3
Date: Thu, 6 Jul 2017 06:13:54 -0400
4
Subject: [PATCH] https://github.com/ImageMagick/ImageMagick/issues/544
5
6
---
7
coders/wmf.c | 5 +++++
8
1 file changed, 5 insertions(+)
9
10
Index: ImageMagick-6.8.8-1/coders/wmf.c
11
===================================================================
12
--- ImageMagick-6.8.8-1.orig/coders/wmf.c 2013-12-22 03:08:38.000000000 +0100
13
+++ ImageMagick-6.8.8-1/coders/wmf.c 2017-10-24 15:58:47.443486950 +0200
14
15
(void *) image);
16
if (wmf_status != wmf_E_None)
17
{
18
+ ipa_device_close(wmf_info);
19
wmf_api_destroy(wmf_info);
20
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
21
image->filename);
22
23
wmf_status=wmf_scan(wmf_info,0,&bounding_box);
24
if (wmf_status != wmf_E_None)
25
{
26
+ ipa_device_close(wmf_info);
27
wmf_api_destroy(wmf_info);
28
ThrowReaderException(DelegateError,"FailedToScanFile");
29
}
30
31
file=fdopen(unique_file,"wb");
32
if ((unique_file == -1) || (file == (FILE *) NULL))
33
{
34
+ ipa_device_close(wmf_info);
35
wmf_api_destroy(wmf_info);
36
ThrowReaderException(FileOpenError,"UnableToCreateTemporaryFile");
37
}
38
39
wmf_status=wmf_play(wmf_info,0,&bounding_box);
40
if (wmf_status != wmf_E_None)
41
{
42
+ ipa_device_close(wmf_info);
43
wmf_api_destroy(wmf_info);
44
ThrowReaderException(DelegateError,"FailedToRenderFile");
45
}
46
47
wmf_magick_t
48
*ddata = WMF_MAGICK_GetData(API);
49
50
- DestroyDrawingWand(ddata->draw_wand);
51
- DestroyDrawInfo(ddata->draw_info);
52
- RelinquishMagickMemory(WMF_MAGICK_GetFontData(API)->ps_name);
53
+ if (ddata->draw_wand != (DrawingWand *) NULL)
54
+ {
55
+ DestroyDrawingWand(ddata->draw_wand);
56
+ ddata->draw_wand=(DrawingWand *) NULL;
57
+ }
58
+ if (ddata->draw_info != (DrawInfo *) NULL)
59
+ {
60
+ DestroyDrawInfo(ddata->draw_info);
61
+ ddata->draw_info=(DrawInfo *)NULL;
62
+ }
63
+ if (WMF_MAGICK_GetFontData(API)->ps_name)
64
+ WMF_MAGICK_GetFontData(API)->ps_name=(char *) RelinquishMagickMemory(
65
+ WMF_MAGICK_GetFontData(API)->ps_name);
66
}
67
68
/*
69
70
wmf_error = wmf_api_create(&API, wmf_options_flags, &wmf_api_options);
71
if (wmf_error != wmf_E_None)
72
{
73
- if (API)
74
- wmf_api_destroy(API);
75
if (image->debug != MagickFalse)
76
{
77
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
78
79
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
80
"leave ReadWMFImage()");
81
}
82
+ if (API)
83
+ wmf_api_destroy(API);
84
ThrowReaderException(DelegateError,"UnableToInitializeWMFLibrary");
85
}
86
87
88
ipa_blob_tell,(void*)image);
89
if (wmf_error != wmf_E_None)
90
{
91
- wmf_api_destroy(API);
92
if (image->debug != MagickFalse)
93
{
94
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
95
96
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
97
"leave ReadWMFImage()");
98
}
99
+ ipa_device_close(API);
100
+ wmf_api_destroy(API);
101
ThrowFileException(exception,FileOpenError,"UnableToOpenFile",
102
image->filename);
103
image=DestroyImageList(image);
104
105
wmf_error=wmf_scan(API, 0, &bbox);
106
if (wmf_error != wmf_E_None)
107
{
108
- wmf_api_destroy(API);
109
if (image->debug != MagickFalse)
110
{
111
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
112
113
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
114
"leave ReadWMFImage()");
115
}
116
+ ipa_device_close(API);
117
+ wmf_api_destroy(API);
118
ThrowReaderException(DelegateError,"FailedToScanFile");
119
}
120
121
122
wmf_error=wmf_size(API,&wmf_width,&wmf_height);
123
if (wmf_error != wmf_E_None)
124
{
125
- wmf_api_destroy(API);
126
if (image->debug != MagickFalse)
127
{
128
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
129
130
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
131
"leave ReadWMFImage()");
132
}
133
+ wmf_api_destroy(API);
134
ThrowReaderException(DelegateError,"FailedToComputeOutputSize");
135
}
136
137
138
wmf_error = wmf_play(API, 0, &bbox);
139
if (wmf_error != wmf_E_None)
140
{
141
- wmf_api_destroy(API);
142
if (image->debug != MagickFalse)
143
{
144
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
145
146
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
147
"leave ReadWMFImage()");
148
}
149
+ wmf_api_destroy(API);
150
ThrowReaderException(DelegateError,"FailedToRenderFile");
151
}
152
153