1
#! /bin/sh /usr/share/dpatch/dpatch-run
2
## 48_cups-output-device-pdf-duplex-uninitialized-memory-fix.dpatch by <till.kamppeter@gmail.com>
4
## All lines beginning with `## DP:' are a description of the patch.
8
diff -urNad ghostscript-8.63.dfsg.1~/cups/gdevcups.c ghostscript-8.63.dfsg.1/cups/gdevcups.c
9
--- ghostscript-8.63.dfsg.1~/cups/gdevcups.c 2007-05-14 20:22:09.000000000 +0200
10
+++ ghostscript-8.63.dfsg.1/cups/gdevcups.c 2008-10-19 12:39:50.000000000 +0200
15
+#ifdef CUPS_RASTER_SYNCv1
17
+ 1, /* cupsNumColors */
18
+ 1.0, /* cupsBorderlessScalingFactor */
19
+ { 612.0, 792.0 }, /* cupsPageSize */
20
+ { 0.0, 0.0, 612.0, 792.0 }, /* cupsImagingBBox */
21
+ { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, /* cupsInteger */
22
+ { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
23
+ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }, /* cupsReal */
24
+ { "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "" },
26
+ "", /* cupsMarkerType */
27
+ "", /* cupsRenderingIntent */
28
+ "Letter" /* cupsPageSizeName */
29
+#endif /* CUPS_RASTER_SYNCv1 */
34
(int *)&(cups->header.CutMedia))) < 0)
37
+ b = cups->header.Duplex;
38
+ if ((code = param_write_bool(plist, "Duplex", &b)) < 0)
41
b = cups->header.InsertSheet;
42
if ((code = param_write_bool(plist, "InsertSheet", &b)) < 0)
45
(int *)&(cups->header.MediaPosition))) < 0)
48
+ if ((code = param_write_int(plist, "MediaWeight",
49
+ (int *)&(cups->header.MediaWeight))) < 0)
52
b = cups->header.MirrorPrint;
53
if ((code = param_write_bool(plist, "MirrorPrint", &b)) < 0)
58
#ifdef CUPS_RASTER_SYNCv1
59
+#if 0 /* Don't include read-only parameters... */
60
if ((code = param_write_int(plist, "cupsNumColors",
61
(int *)&(cups->header.cupsNumColors))) < 0)
65
if ((code = param_write_float(plist, "cupsBorderlessScalingFactor",
66
&(cups->header.cupsBorderlessScalingFactor))) < 0)
68
for (i = 0; i < 16; i ++)
70
sprintf(name, "cupsInteger%d", i);
71
- if ((code = param_write_int(plist, name,
72
+ if ((code = param_write_int(plist, strdup(name),
73
(int *)(cups->header.cupsInteger + i))) < 0)
77
for (i = 0; i < 16; i ++)
79
sprintf(name, "cupsReal%d", i);
80
- if ((code = param_write_float(plist, name,
81
+ if ((code = param_write_float(plist, strdup(name),
82
cups->header.cupsReal + i)) < 0)
86
for (i = 0; i < 16; i ++)
88
- sprintf(name, "cupsReal%d", i);
89
+ sprintf(name, "cupsString%d", i);
90
param_string_from_string(s, cups->header.cupsString[i]);
91
- if ((code = param_write_string(plist, name, &s)) < 0)
92
+ if ((code = param_write_string(plist, strdup(name), &s)) < 0)
96
@@ -2695,11 +2720,15 @@
97
#define stringoption(name, sname) \
98
if ((code = param_read_string(plist, sname, &stringval)) < 0) \
100
+ dprintf2("ERROR: Error setting %s to \"%s\"...\n", sname, \
101
+ (char *)stringval.data); \
102
param_signal_error(plist, sname, code); \
105
else if (code == 0) \
107
+ dprintf2("DEBUG: Setting %s to \"%s\"...\n", sname, \
108
+ (char *)stringval.data); \
109
strncpy(cups->header.name, (const char *)stringval.data, \
111
cups->header.name[stringval.size] = '\0'; \
112
@@ -2708,29 +2737,35 @@
113
#define intoption(name, sname, type) \
114
if ((code = param_read_int(plist, sname, &intval)) < 0) \
116
+ dprintf2("ERROR: Error setting %s to %d...\n", sname, (int)intval); \
117
param_signal_error(plist, sname, code); \
120
else if (code == 0) \
122
- dprintf2("DEBUG: Setting %s to %d...\n", sname, intval); \
123
+ dprintf2("DEBUG: Setting %s to %d...\n", sname, (int)intval); \
124
cups->header.name = (type)intval; \
127
#define floatoption(name, sname) \
128
if ((code = param_read_float(plist, sname, &floatval)) < 0) \
130
+ dprintf2("ERROR: Error setting %s to %.4f...\n", sname, (float)floatval); \
131
param_signal_error(plist, sname, code); \
134
else if (code == 0) \
135
- cups->header.name = (unsigned)floatval;
137
+ dprintf2("DEBUG: Setting %s to %.4f...\n", sname, (float)floatval); \
138
+ cups->header.name = (float)floatval; \
141
#define booloption(name, sname) \
142
if ((code = param_read_bool(plist, sname, &boolval)) < 0) \
144
if ((code = param_read_null(plist, sname)) < 0) \
146
+ dprintf2("ERROR: Error setting %s to %d...\n", sname, (int)boolval); \
147
param_signal_error(plist, sname, code); \
150
@@ -2738,24 +2773,34 @@
151
cups->header.name = CUPS_FALSE; \
153
else if (code == 0) \
154
- cups->header.name = (cups_bool_t)boolval;
156
+ dprintf2("DEBUG: Setting %s to %d...\n", sname, (int)boolval); \
157
+ cups->header.name = (cups_bool_t)boolval; \
160
#define arrayoption(name, sname, count) \
161
if ((code = param_read_float_array(plist, sname, &arrayval)) < 0) \
163
if ((code = param_read_null(plist, sname)) < 0) \
165
+ dprintf1("ERROR: Error setting %s...\n", sname); \
166
param_signal_error(plist, sname, code); \
171
+ dprintf1("DEBUG: Setting %s to zero\n", sname); \
172
for (i = 0; i < count; i ++) \
173
cups->header.name[i] = 0; \
176
else if (code == 0) \
178
+ dprintf1("DEBUG: Setting %s to", sname); \
179
for (i = 0; i < count; i ++) \
180
+ dprintf1(" %d", (unsigned)(arrayval.data[i])); \
181
cups->header.name[i] = (unsigned)arrayval.data[i]; \
182
+ dprintf("...\n"); \
185
size_set = param_read_float_array(plist, ".MediaSize", &arrayval) == 0 ||
186
@@ -2768,7 +2813,7 @@
187
stringoption(MediaColor, "MediaColor")
188
stringoption(MediaType, "MediaType")
189
stringoption(OutputType, "OutputType")
190
- floatoption(AdvanceDistance, "AdvanceDistance")
191
+ intoption(AdvanceDistance, "AdvanceDistance", unsigned)
192
intoption(AdvanceMedia, "AdvanceMedia", cups_adv_t)
193
booloption(Collate, "Collate")
194
intoption(CutMedia, "CutMedia", cups_cut_t)
195
@@ -2781,7 +2826,7 @@
196
booloption(ManualFeed, "ManualFeed")
197
intoption(MediaPosition, "cupsMediaPosition", unsigned) /* Compatibility */
198
intoption(MediaPosition, "MediaPosition", unsigned)
199
- floatoption(MediaWeight, "MediaWeight")
200
+ intoption(MediaWeight, "MediaWeight", unsigned)
201
booloption(MirrorPrint, "MirrorPrint")
202
booloption(NegativePrint, "NegativePrint")
203
intoption(Orientation, "Orientation", cups_orient_t)
204
@@ -2815,19 +2860,19 @@
205
for (i = 0; i < 16; i ++)
207
sprintf(name, "cupsInteger%d", i);
208
- intoption(cupsInteger[i], name, unsigned)
209
+ intoption(cupsInteger[i],strdup(name), unsigned)
212
for (i = 0; i < 16; i ++)
214
sprintf(name, "cupsReal%d", i);
215
- floatoption(cupsReal[i], name)
216
+ floatoption(cupsReal[i], strdup(name))
219
for (i = 0; i < 16; i ++)
221
sprintf(name, "cupsString%d", i);
222
- stringoption(cupsString[i], name)
223
+ stringoption(cupsString[i], strdup(name))
226
stringoption(cupsMarkerType, "cupsMarkerType");