diff options
-rw-r--r-- | meta-oe/recipes-printing/cups/libppd/0001-CVE-2024-47175.patch | 600 | ||||
-rw-r--r-- | meta-oe/recipes-printing/cups/libppd_2.0.0.bb | 5 |
2 files changed, 604 insertions, 1 deletions
diff --git a/meta-oe/recipes-printing/cups/libppd/0001-CVE-2024-47175.patch b/meta-oe/recipes-printing/cups/libppd/0001-CVE-2024-47175.patch new file mode 100644 index 0000000000..ba9cc683af --- /dev/null +++ b/meta-oe/recipes-printing/cups/libppd/0001-CVE-2024-47175.patch | |||
@@ -0,0 +1,600 @@ | |||
1 | From 67a96c1e81bf219a5eefb81b513cf1f44d1a3700 Mon Sep 17 00:00:00 2001 | ||
2 | From: Zdenek Dohnal <zdohnal@redhat.com> | ||
3 | Date: Thu, 26 Sep 2024 23:12:14 +0200 | ||
4 | Subject: [PATCH] CVE-2024-47175 | ||
5 | |||
6 | Prevent PPD generation based on invalid IPP response | ||
7 | |||
8 | Author: Mike Sweet | ||
9 | Minor fixes: Zdenek Dohnal | ||
10 | |||
11 | CVE: CVE-2024-47175 | ||
12 | Upstream-Status: Backport [https://github.com/OpenPrinting/libppd/commit/d681747ebf12602cb426725eb8ce2753211e2477] | ||
13 | |||
14 | (cherry picked from commit d681747ebf12602cb426725eb8ce2753211e2477) | ||
15 | Signed-off-by: Ankur Tyagi <ankur.tyagi85@gmail.com> | ||
16 | --- | ||
17 | ppd/ppd-cache.c | 17 ++- | ||
18 | ppd/ppd-generator.c | 257 ++++++++++++++++++++++++++++---------------- | ||
19 | 2 files changed, 176 insertions(+), 98 deletions(-) | ||
20 | |||
21 | diff --git a/ppd/ppd-cache.c b/ppd/ppd-cache.c | ||
22 | index 5aa617c1..747c9ad5 100644 | ||
23 | --- a/ppd/ppd-cache.c | ||
24 | +++ b/ppd/ppd-cache.c | ||
25 | @@ -1,6 +1,7 @@ | ||
26 | // | ||
27 | // PPD cache implementation for libppd. | ||
28 | // | ||
29 | +// Copyright © 2024 by OpenPrinting | ||
30 | // Copyright © 2010-2019 by Apple Inc. | ||
31 | // | ||
32 | // Licensed under Apache License v2.0. See the file "LICENSE" for more | ||
33 | @@ -3413,7 +3414,7 @@ ppdCacheGetBin( | ||
34 | |||
35 | // | ||
36 | // Range check input... | ||
37 | - | ||
38 | + | ||
39 | |||
40 | if (!pc || !output_bin) | ||
41 | return (NULL); | ||
42 | @@ -3914,7 +3915,7 @@ ppdCacheGetPageSize( | ||
43 | { | ||
44 | // | ||
45 | // Check not only the base size (like "A4") but also variants (like | ||
46 | - // "A4.Borderless"). We check only the margins and orientation but do | ||
47 | + // "A4.Borderless"). We check only the margins and orientation but do | ||
48 | // not re-check the size. | ||
49 | // | ||
50 | |||
51 | @@ -4711,7 +4712,7 @@ ppdPwgPpdizeName(const char *ipp, // I - IPP keyword | ||
52 | *end; // End of name buffer | ||
53 | |||
54 | |||
55 | - if (!ipp) | ||
56 | + if (!ipp || !_ppd_isalnum(*ipp)) | ||
57 | { | ||
58 | *name = '\0'; | ||
59 | return; | ||
60 | @@ -4721,13 +4722,19 @@ ppdPwgPpdizeName(const char *ipp, // I - IPP keyword | ||
61 | |||
62 | for (ptr = name + 1, end = name + namesize - 1; *ipp && ptr < end;) | ||
63 | { | ||
64 | - if (*ipp == '-' && _ppd_isalnum(ipp[1])) | ||
65 | + if (*ipp == '-' && isalnum(ipp[1])) | ||
66 | { | ||
67 | ipp ++; | ||
68 | *ptr++ = (char)toupper(*ipp++ & 255); | ||
69 | } | ||
70 | - else | ||
71 | + else if (*ipp == '_' || *ipp == '.' || *ipp == '-' || isalnum(*ipp)) | ||
72 | + { | ||
73 | *ptr++ = *ipp++; | ||
74 | + } | ||
75 | + else | ||
76 | + { | ||
77 | + ipp ++; | ||
78 | + } | ||
79 | } | ||
80 | |||
81 | *ptr = '\0'; | ||
82 | diff --git a/ppd/ppd-generator.c b/ppd/ppd-generator.c | ||
83 | index a815030b..011e086e 100644 | ||
84 | --- a/ppd/ppd-generator.c | ||
85 | +++ b/ppd/ppd-generator.c | ||
86 | @@ -1,15 +1,16 @@ | ||
87 | // | ||
88 | // PWG Raster/Apple Raster/PCLm/PDF/IPP legacy PPD generator for libppd. | ||
89 | // | ||
90 | -// Copyright 2016-2019 by Till Kamppeter. | ||
91 | -// Copyright 2017-2019 by Sahil Arora. | ||
92 | -// Copyright 2018-2019 by Deepak Patankar. | ||
93 | +// Copyright © 2024 by OpenPrinting | ||
94 | +// Copyright © 2016-2019 by Till Kamppeter. | ||
95 | +// Copyright © 2017-2019 by Sahil Arora. | ||
96 | +// Copyright © 2018-2019 by Deepak Patankar. | ||
97 | // | ||
98 | // The PPD generator is based on the PPD generator for the CUPS | ||
99 | // "lpadmin -m everywhere" functionality in the cups/ppd-cache.c | ||
100 | // file. The copyright of this file is: | ||
101 | // | ||
102 | -// Copyright 2010-2016 by Apple Inc. | ||
103 | +// Copyright © 2010-2016 by Apple Inc. | ||
104 | // | ||
105 | // Licensed under Apache License v2.0. See the file "LICENSE" for more | ||
106 | // information. | ||
107 | @@ -51,6 +52,7 @@ | ||
108 | |||
109 | static int http_connect(http_t **http, const char *url, char *resource, | ||
110 | size_t ressize); | ||
111 | +static void ppd_put_string(cups_file_t *fp, cups_lang_t *lang, const char *ppd_option, const char *ppd_choice, const char *pwg_msgid); | ||
112 | |||
113 | |||
114 | // | ||
115 | @@ -60,7 +62,7 @@ static int http_connect(http_t **http, const char *url, char *resource, | ||
116 | // than CUPS 2.2.x. We have also an additional test and development | ||
117 | // platform for this code. Taken from cups/ppd-cache.c, | ||
118 | // cups/string-private.h, cups/string.c. | ||
119 | -// | ||
120 | +// | ||
121 | // The advantage of PPD generation instead of working with System V | ||
122 | // interface scripts is that the print dialogs of the clients do not | ||
123 | // need to ask the printer for its options via IPP. So we have access | ||
124 | @@ -124,7 +126,7 @@ char ppdgenerator_msg[1024]; | ||
125 | // IPP 1.x legacy) | ||
126 | // | ||
127 | |||
128 | -char * // O - PPD filename or NULL | ||
129 | +char * // O - PPD filename or NULL | ||
130 | // on error | ||
131 | ppdCreatePPDFromIPP(char *buffer, // I - Filename buffer | ||
132 | size_t bufsize, // I - Size of filename | ||
133 | @@ -175,7 +177,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
134 | cups_array_t *conflicts, // I - Array of | ||
135 | // constraints | ||
136 | cups_array_t *sizes, // I - Media sizes we've | ||
137 | - // added | ||
138 | + // added | ||
139 | char* default_pagesize, // I - Default page size | ||
140 | const char *default_cluster_color, // I - cluster def | ||
141 | // color (if cluster's | ||
142 | @@ -187,6 +189,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
143 | size_t status_msg_size) // I - Size of status | ||
144 | // message buffer | ||
145 | { | ||
146 | + cups_lang_t *lang; // Localization language | ||
147 | cups_file_t *fp; // PPD file | ||
148 | cups_array_t *printer_sizes; // Media sizes we've added | ||
149 | cups_size_t *size; // Current media size | ||
150 | @@ -199,9 +202,10 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
151 | ipp_t *media_col, // Media collection | ||
152 | *media_size; // Media size collection | ||
153 | char make[256], // Make and model | ||
154 | - *model, // Model name | ||
155 | + *mptr, // Pointer into make and model | ||
156 | ppdname[PPD_MAX_NAME]; | ||
157 | // PPD keyword | ||
158 | + const char *model; // Model name | ||
159 | int i, j, // Looping vars | ||
160 | count = 0, // Number of values | ||
161 | bottom, // Largest bottom margin | ||
162 | @@ -283,6 +287,68 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
163 | return (NULL); | ||
164 | } | ||
165 | |||
166 | + // | ||
167 | + // Get a sanitized make and model... | ||
168 | + // | ||
169 | + | ||
170 | + if ((attr = ippFindAttribute(supported, "printer-make-and-model", IPP_TAG_TEXT)) != NULL && ippValidateAttribute(attr)) | ||
171 | + { | ||
172 | + // Sanitize the model name to only contain PPD-safe characters. | ||
173 | + strlcpy(make, ippGetString(attr, 0, NULL), sizeof(make)); | ||
174 | + | ||
175 | + for (mptr = make; *mptr; mptr ++) | ||
176 | + { | ||
177 | + if (*mptr < ' ' || *mptr >= 127 || *mptr == '\"') | ||
178 | + { | ||
179 | + // Truncate the make and model on the first bad character... | ||
180 | + *mptr = '\0'; | ||
181 | + break; | ||
182 | + } | ||
183 | + } | ||
184 | + | ||
185 | + while (mptr > make) | ||
186 | + { | ||
187 | + // Strip trailing whitespace... | ||
188 | + mptr --; | ||
189 | + if (*mptr == ' ') | ||
190 | + *mptr = '\0'; | ||
191 | + } | ||
192 | + | ||
193 | + if (!make[0]) | ||
194 | + { | ||
195 | + // Use a default make and model if nothing remains... | ||
196 | + strlcpy(make, "Unknown", sizeof(make)); | ||
197 | + } | ||
198 | + } | ||
199 | + else | ||
200 | + { | ||
201 | + // Use a default make and model... | ||
202 | + strlcpy(make, "Unknown", sizeof(make)); | ||
203 | + } | ||
204 | + | ||
205 | + if (!strncasecmp(make, "Hewlett Packard ", 16) || !strncasecmp(make, "Hewlett-Packard ", 16)) | ||
206 | + { | ||
207 | + // Normalize HP printer make and model... | ||
208 | + model = make + 16; | ||
209 | + strlcpy(make, "HP", sizeof(make)); | ||
210 | + | ||
211 | + if (!strncasecmp(model, "HP ", 3)) | ||
212 | + model += 3; | ||
213 | + } | ||
214 | + else if ((mptr = strchr(make, ' ')) != NULL) | ||
215 | + { | ||
216 | + // Separate "MAKE MODEL"... | ||
217 | + while (*mptr && *mptr == ' ') | ||
218 | + *mptr++ = '\0'; | ||
219 | + | ||
220 | + model = mptr; | ||
221 | + } | ||
222 | + else | ||
223 | + { | ||
224 | + // No separate model name... | ||
225 | + model = "Printer"; | ||
226 | + } | ||
227 | + | ||
228 | // | ||
229 | // Standard stuff for PPD file... | ||
230 | // | ||
231 | @@ -311,25 +377,6 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
232 | } | ||
233 | } | ||
234 | |||
235 | - if ((attr = ippFindAttribute(supported, "printer-make-and-model", | ||
236 | - IPP_TAG_TEXT)) != NULL) | ||
237 | - strlcpy(make, ippGetString(attr, 0, NULL), sizeof(make)); | ||
238 | - else if (make_model && make_model[0] != '\0') | ||
239 | - strlcpy(make, make_model, sizeof(make)); | ||
240 | - else | ||
241 | - strlcpy(make, "Unknown Printer", sizeof(make)); | ||
242 | - | ||
243 | - if (!strncasecmp(make, "Hewlett Packard ", 16) || | ||
244 | - !strncasecmp(make, "Hewlett-Packard ", 16)) | ||
245 | - { | ||
246 | - model = make + 16; | ||
247 | - strlcpy(make, "HP", sizeof(make)); | ||
248 | - } | ||
249 | - else if ((model = strchr(make, ' ')) != NULL) | ||
250 | - *model++ = '\0'; | ||
251 | - else | ||
252 | - model = make; | ||
253 | - | ||
254 | cupsFilePrintf(fp, "*Manufacturer: \"%s\"\n", make); | ||
255 | cupsFilePrintf(fp, "*ModelName: \"%s %s\"\n", make, model); | ||
256 | cupsFilePrintf(fp, "*Product: \"(%s %s)\"\n", make, model); | ||
257 | @@ -425,21 +472,19 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
258 | } | ||
259 | cupsFilePuts(fp, "\"\n"); | ||
260 | |||
261 | - if ((attr = ippFindAttribute(supported, "printer-more-info", IPP_TAG_URI)) != | ||
262 | - NULL) | ||
263 | + if ((attr = ippFindAttribute(supported, "printer-more-info", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr)) | ||
264 | cupsFilePrintf(fp, "*APSupplies: \"%s\"\n", ippGetString(attr, 0, NULL)); | ||
265 | |||
266 | - if ((attr = ippFindAttribute(supported, "printer-charge-info-uri", | ||
267 | - IPP_TAG_URI)) != NULL) | ||
268 | - cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0, | ||
269 | - NULL)); | ||
270 | + if ((attr = ippFindAttribute(supported, "printer-charge-info-uri", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr)) | ||
271 | + cupsFilePrintf(fp, "*cupsChargeInfoURI: \"%s\"\n", ippGetString(attr, 0, NULL)); | ||
272 | |||
273 | // Message catalogs for UI strings | ||
274 | + lang = cupsLangDefault(); | ||
275 | opt_strings_catalog = cfCatalogOptionArrayNew(); | ||
276 | cfCatalogLoad(NULL, NULL, opt_strings_catalog); | ||
277 | |||
278 | if ((attr = ippFindAttribute(supported, "printer-strings-uri", | ||
279 | - IPP_TAG_URI)) != NULL) | ||
280 | + IPP_TAG_URI)) != NULL && ippValidateAttribute(attr)) | ||
281 | { | ||
282 | printer_opt_strings_catalog = cfCatalogOptionArrayNew(); | ||
283 | cfCatalogLoad(ippGetString(attr, 0, NULL), NULL, | ||
284 | @@ -492,7 +537,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
285 | response = cupsDoRequest(http, request, resource); | ||
286 | |||
287 | if ((attr = ippFindAttribute(response, "printer-strings-uri", | ||
288 | - IPP_TAG_URI)) != NULL) | ||
289 | + IPP_TAG_URI)) != NULL && ippValidateAttribute(attr)) | ||
290 | cupsFilePrintf(fp, "*cupsStringsURI %s: \"%s\"\n", keyword, | ||
291 | ippGetString(attr, 0, NULL)); | ||
292 | |||
293 | @@ -518,13 +563,10 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
294 | IPP_TAG_BOOLEAN), 0)) | ||
295 | cupsFilePuts(fp, "*cupsJobAccountingUserId: True\n"); | ||
296 | |||
297 | - if ((attr = ippFindAttribute(supported, "printer-privacy-policy-uri", | ||
298 | - IPP_TAG_URI)) != NULL) | ||
299 | - cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", | ||
300 | - ippGetString(attr, 0, NULL)); | ||
301 | + if ((attr = ippFindAttribute(supported, "printer-privacy-policy-uri", IPP_TAG_URI)) != NULL && ippValidateAttribute(attr)) | ||
302 | + cupsFilePrintf(fp, "*cupsPrivacyURI: \"%s\"\n", ippGetString(attr, 0, NULL)); | ||
303 | |||
304 | - if ((attr = ippFindAttribute(supported, "printer-mandatory-job-attributes", | ||
305 | - IPP_TAG_KEYWORD)) != NULL) | ||
306 | + if ((attr = ippFindAttribute(supported, "printer-mandatory-job-attributes", IPP_TAG_KEYWORD)) != NULL && ippValidateAttribute(attr)) | ||
307 | { | ||
308 | char prefix = '\"'; // Prefix for string | ||
309 | |||
310 | @@ -544,8 +586,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
311 | cupsFilePuts(fp, "\"\n"); | ||
312 | } | ||
313 | |||
314 | - if ((attr = ippFindAttribute(supported, "printer-requested-job-attributes", | ||
315 | - IPP_TAG_KEYWORD)) != NULL) | ||
316 | + if ((attr = ippFindAttribute(supported, "printer-requested-job-attributes", IPP_TAG_KEYWORD)) != NULL && ippValidateAttribute(attr)) | ||
317 | { | ||
318 | char prefix = '\"'; // Prefix for string | ||
319 | |||
320 | @@ -664,7 +705,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
321 | } | ||
322 | |||
323 | // | ||
324 | - // Fax | ||
325 | + // Fax | ||
326 | // | ||
327 | |||
328 | if (is_fax) | ||
329 | @@ -705,21 +746,21 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
330 | #ifdef CUPS_RASTER_HAVE_APPLERASTER | ||
331 | else if (cupsArrayFind(pdl_list, "image/urf")) | ||
332 | { | ||
333 | - int resStore = 0; // Variable for storing the no. of resolutions in the resolution array | ||
334 | + int resStore = 0; // Variable for storing the no. of resolutions in the resolution array | ||
335 | int resArray[__INT16_MAX__]; // Creating a resolution array supporting a maximum of 32767 resolutions. | ||
336 | int lowdpi = 0, middpi = 0, hidpi = 0; // Lower , middle and higher resolution | ||
337 | if ((attr = ippFindAttribute(supported, "urf-supported", | ||
338 | IPP_TAG_KEYWORD)) != NULL) | ||
339 | { | ||
340 | for (int i = 0, count = ippGetCount(attr); i < count; i ++) | ||
341 | - { | ||
342 | + { | ||
343 | const char *rs = ippGetString(attr, i, NULL); // RS values | ||
344 | - const char *rsCopy = ippGetString(attr, i, NULL); // RS values(copy) | ||
345 | + const char *rsCopy = ippGetString(attr, i, NULL); // RS values(copy) | ||
346 | if (strncasecmp(rs, "RS", 2)) // Comparing attributes to have RS in | ||
347 | // the beginning to indicate the | ||
348 | // resolution feature | ||
349 | continue; | ||
350 | - int resCount = 0; // Using a count variable which can be reset | ||
351 | + int resCount = 0; // Using a count variable which can be reset | ||
352 | while (*rsCopy != '\0') // Parsing through the copy pointer to | ||
353 | // determine the no. of resolutions | ||
354 | { | ||
355 | @@ -817,7 +858,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
356 | formatfound = 1; | ||
357 | is_apple = 1; | ||
358 | } | ||
359 | - } | ||
360 | + } | ||
361 | } | ||
362 | } | ||
363 | } | ||
364 | @@ -909,7 +950,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
365 | if (manual_copies == 1) | ||
366 | cupsFilePuts(fp, "*cupsManualCopies: True\n"); | ||
367 | |||
368 | - // No resolution requirements by any of the supported PDLs? | ||
369 | + // No resolution requirements by any of the supported PDLs? | ||
370 | // Use "printer-resolution-supported" attribute | ||
371 | if (common_res == NULL) | ||
372 | { | ||
373 | @@ -1027,7 +1068,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
374 | // | ||
375 | // PageSize/PageRegion/ImageableArea/PaperDimension | ||
376 | // | ||
377 | - | ||
378 | + | ||
379 | cfGenerateSizes(supported, CF_GEN_SIZES_DEFAULT, &printer_sizes, &defattr, | ||
380 | NULL, NULL, NULL, NULL, NULL, NULL, | ||
381 | &min_width, &min_length, | ||
382 | @@ -1406,15 +1447,15 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
383 | if (!strcmp(sources[j], keyword)) | ||
384 | break; | ||
385 | if (j >= 0) | ||
386 | - cupsFilePrintf(fp, "*InputSlot %s%s%s: \"<</MediaPosition %d>>setpagedevice\"\n", | ||
387 | - ppdname, | ||
388 | - (human_readable ? "/" : ""), | ||
389 | - (human_readable ? human_readable : ""), j); | ||
390 | + { | ||
391 | + cupsFilePrintf(fp, "*InputSlot %s: \"<</MediaPosition %d>>setpagedevice\"\n", ppdname, j); | ||
392 | + ppd_put_string(fp, lang, "InputSlot", ppdname, human_readable); | ||
393 | + } | ||
394 | else | ||
395 | - cupsFilePrintf(fp, "*InputSlot %s%s%s: \"\"\n", | ||
396 | - ppdname, | ||
397 | - (human_readable ? "/" : ""), | ||
398 | - (human_readable ? human_readable : "")); | ||
399 | + { | ||
400 | + cupsFilePrintf(fp, "*InputSlot %s%s%s:\"\"\n", ppdname, human_readable ? "/" : "", human_readable ? human_readable : ""); | ||
401 | + ppd_put_string(fp, lang, "InputSlot", ppdname, human_readable); | ||
402 | + } | ||
403 | } | ||
404 | cupsFilePuts(fp, "*CloseUI: *InputSlot\n"); | ||
405 | } | ||
406 | @@ -1449,11 +1490,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
407 | human_readable = cfCatalogLookUpChoice((char *)keyword, "media-type", | ||
408 | opt_strings_catalog, | ||
409 | printer_opt_strings_catalog); | ||
410 | - cupsFilePrintf(fp, "*MediaType %s%s%s: \"<</MediaType(%s)>>setpagedevice\"\n", | ||
411 | - ppdname, | ||
412 | - (human_readable ? "/" : ""), | ||
413 | - (human_readable ? human_readable : ""), | ||
414 | - ppdname); | ||
415 | + cupsFilePrintf(fp, "*MediaType %s: \"<</MediaType(%s)>>setpagedevice\"\n", ppdname, ppdname); | ||
416 | + ppd_put_string(fp, lang, "MediaType", ppdname, human_readable); | ||
417 | } | ||
418 | cupsFilePuts(fp, "*CloseUI: *MediaType\n"); | ||
419 | } | ||
420 | @@ -1776,10 +1814,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
421 | human_readable = cfCatalogLookUpChoice((char *)keyword, "output-bin", | ||
422 | opt_strings_catalog, | ||
423 | printer_opt_strings_catalog); | ||
424 | - cupsFilePrintf(fp, "*OutputBin %s%s%s: \"\"\n", | ||
425 | - ppdname, | ||
426 | - (human_readable ? "/" : ""), | ||
427 | - (human_readable ? human_readable : "")); | ||
428 | + cupsFilePrintf(fp, "*OutputBin %s: \"\"\n", ppdname); | ||
429 | + ppd_put_string(fp, lang, "OutputBin", ppdname, human_readable); | ||
430 | outputorderinfofound = 0; | ||
431 | faceupdown = 1; | ||
432 | firsttolast = 1; | ||
433 | @@ -1833,7 +1869,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
434 | |||
435 | // | ||
436 | // Finishing options... | ||
437 | - // | ||
438 | + // | ||
439 | |||
440 | if ((attr = ippFindAttribute(supported, "finishings-supported", | ||
441 | IPP_TAG_ENUM)) != NULL) | ||
442 | @@ -1958,9 +1994,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
443 | human_readable = cfCatalogLookUpChoice(buf, "finishings", | ||
444 | opt_strings_catalog, | ||
445 | printer_opt_strings_catalog); | ||
446 | - cupsFilePrintf(fp, "*StapleLocation %s%s%s: \"\"\n", ppd_keyword, | ||
447 | - (human_readable ? "/" : ""), | ||
448 | - (human_readable ? human_readable : "")); | ||
449 | + cupsFilePrintf(fp, "*StapleLocation %s: \"\"\n", ppd_keyword); | ||
450 | + ppd_put_string(fp, lang, "StapleLocation", ppd_keyword, human_readable); | ||
451 | cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*StapleLocation %s\"\n", | ||
452 | value, keyword, ppd_keyword); | ||
453 | } | ||
454 | @@ -2050,9 +2085,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
455 | human_readable = cfCatalogLookUpChoice(buf, "finishings", | ||
456 | opt_strings_catalog, | ||
457 | printer_opt_strings_catalog); | ||
458 | - cupsFilePrintf(fp, "*FoldType %s%s%s: \"\"\n", ppd_keyword, | ||
459 | - (human_readable ? "/" : ""), | ||
460 | - (human_readable ? human_readable : "")); | ||
461 | + cupsFilePrintf(fp, "*FoldType %s: \"\"\n", ppd_keyword); | ||
462 | + ppd_put_string(fp, lang, "FoldType", ppd_keyword, human_readable); | ||
463 | cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*FoldType %s\"\n", | ||
464 | value, keyword, ppd_keyword); | ||
465 | } | ||
466 | @@ -2149,9 +2183,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
467 | human_readable = cfCatalogLookUpChoice(buf, "finishings", | ||
468 | opt_strings_catalog, | ||
469 | printer_opt_strings_catalog); | ||
470 | - cupsFilePrintf(fp, "*PunchMedia %s%s%s: \"\"\n", ppd_keyword, | ||
471 | - (human_readable ? "/" : ""), | ||
472 | - (human_readable ? human_readable : "")); | ||
473 | + cupsFilePrintf(fp, "*PunchMedia %s: \"\"\n", ppd_keyword); | ||
474 | + ppd_put_string(fp, lang, "PunchMedia", ppd_keyword, human_readable); | ||
475 | cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*PunchMedia %s\"\n", | ||
476 | value, keyword, ppd_keyword); | ||
477 | } | ||
478 | @@ -2242,9 +2275,8 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
479 | human_readable = cfCatalogLookUpChoice(buf, "finishings", | ||
480 | opt_strings_catalog, | ||
481 | printer_opt_strings_catalog); | ||
482 | - cupsFilePrintf(fp, "*CutMedia %s%s%s: \"\"\n", ppd_keyword, | ||
483 | - (human_readable ? "/" : ""), | ||
484 | - (human_readable ? human_readable : "")); | ||
485 | + cupsFilePrintf(fp, "*CutMedia %s: \"\"\n", ppd_keyword); | ||
486 | + ppd_put_string(fp, lang, "CutMedia", ppd_keyword, human_readable); | ||
487 | cupsFilePrintf(fp, "*cupsIPPFinishings %d/%s: \"*CutMedia %s\"\n", | ||
488 | value, keyword, ppd_keyword); | ||
489 | } | ||
490 | @@ -2268,7 +2300,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
491 | cupsFilePrintf(fp, "*OpenUI *cupsFinishingTemplate/%s: PickOne\n", | ||
492 | (human_readable ? human_readable : "Finishing Template")); | ||
493 | cupsFilePuts(fp, "*OrderDependency: 10 AnySetup *cupsFinishingTemplate\n"); | ||
494 | - cupsFilePuts(fp, "*DefaultcupsFinishingTemplate: none\n"); | ||
495 | + cupsFilePuts(fp, "*DefaultcupsFinishingTemplate: None\n"); | ||
496 | human_readable = cfCatalogLookUpChoice("3", "finishings", | ||
497 | opt_strings_catalog, | ||
498 | printer_opt_strings_catalog); | ||
499 | @@ -2299,8 +2331,9 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
500 | printer_opt_strings_catalog); | ||
501 | if (human_readable == NULL) | ||
502 | human_readable = (char *)keyword; | ||
503 | - cupsFilePrintf(fp, "*cupsFinishingTemplate %s/%s: \"\n", keyword, | ||
504 | - human_readable); | ||
505 | + ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname)); | ||
506 | + cupsFilePrintf(fp, "*cupsFinishingTemplate %s: \"\n", ppdname); | ||
507 | + ppd_put_string(fp, lang, "cupsFinishingTemplate", ppdname, human_readable); | ||
508 | for (finishing_attr = ippFirstAttribute(finishing_col); finishing_attr; | ||
509 | finishing_attr = ippNextAttribute(finishing_col)) { | ||
510 | if (ippGetValueTag(finishing_attr) == IPP_TAG_BEGIN_COLLECTION) { | ||
511 | @@ -2564,14 +2597,14 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
512 | if (!preset || !preset_name) | ||
513 | continue; | ||
514 | |||
515 | - if ((localized_name = | ||
516 | + ppdPwgPpdizeName(preset_name, ppdname, sizeof(ppdname)); | ||
517 | + | ||
518 | + localized_name = | ||
519 | cfCatalogLookUpOption((char *)preset_name, | ||
520 | opt_strings_catalog, | ||
521 | - printer_opt_strings_catalog)) == NULL) | ||
522 | - cupsFilePrintf(fp, "*APPrinterPreset %s: \"\n", preset_name); | ||
523 | - else | ||
524 | - cupsFilePrintf(fp, "*APPrinterPreset %s/%s: \"\n", preset_name, | ||
525 | - localized_name); | ||
526 | + printer_opt_strings_catalog); | ||
527 | + cupsFilePrintf(fp, "*APPrinterPreset %s: \"\n", ppdname); | ||
528 | + ppd_put_string(fp, lang, "APPrinterPreset", ppdname, localized_name); | ||
529 | |||
530 | for (member = ippFirstAttribute(preset); member; | ||
531 | member = ippNextAttribute(preset)) | ||
532 | @@ -2620,7 +2653,10 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
533 | ippGetString(ippFindAttribute(fin_col, | ||
534 | "finishing-template", | ||
535 | IPP_TAG_ZERO), 0, NULL)) != NULL) | ||
536 | - cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", keyword); | ||
537 | + { | ||
538 | + ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname)); | ||
539 | + cupsFilePrintf(fp, "*cupsFinishingTemplate %s\n", ppdname); | ||
540 | + } | ||
541 | } | ||
542 | } | ||
543 | else if (!strcmp(member_name, "media")) | ||
544 | @@ -2659,7 +2695,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
545 | NULL)) != NULL) | ||
546 | { | ||
547 | ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname)); | ||
548 | - cupsFilePrintf(fp, "*InputSlot %s\n", keyword); | ||
549 | + cupsFilePrintf(fp, "*InputSlot %s\n", ppdname); | ||
550 | } | ||
551 | |||
552 | if ((keyword = ippGetString(ippFindAttribute(media_col, "media-type", | ||
553 | @@ -2667,7 +2703,7 @@ ppdCreatePPDFromIPP2(char *buffer, // I - Filename buffer | ||
554 | NULL)) != NULL) | ||
555 | { | ||
556 | ppdPwgPpdizeName(keyword, ppdname, sizeof(ppdname)); | ||
557 | - cupsFilePrintf(fp, "*MediaType %s\n", keyword); | ||
558 | + cupsFilePrintf(fp, "*MediaType %s\n", ppdname); | ||
559 | } | ||
560 | } | ||
561 | else if (!strcmp(member_name, "print-quality")) | ||
562 | @@ -2817,3 +2853,38 @@ http_connect(http_t **http, // IO - Current HTTP connection | ||
563 | |||
564 | return (*http != NULL); | ||
565 | } | ||
566 | + | ||
567 | + | ||
568 | +/* | ||
569 | + * 'ppd_put_strings()' - Write localization attributes to a PPD file. | ||
570 | + */ | ||
571 | + | ||
572 | +static void | ||
573 | +ppd_put_string(cups_file_t *fp, /* I - PPD file */ | ||
574 | + cups_lang_t *lang, /* I - Language */ | ||
575 | + const char *ppd_option,/* I - PPD option */ | ||
576 | + const char *ppd_choice,/* I - PPD choice */ | ||
577 | + const char *text) /* I - Localized text */ | ||
578 | +{ | ||
579 | + if (!text) | ||
580 | + return; | ||
581 | + | ||
582 | + // Add the first line of localized text... | ||
583 | +#if CUPS_VERSION_MAJOR > 2 | ||
584 | + cupsFilePrintf(fp, "*%s.%s %s/", cupsLangGetName(lang), ppd_option, ppd_choice); | ||
585 | +#else | ||
586 | + cupsFilePrintf(fp, "*%s.%s %s/", lang->language, ppd_option, ppd_choice); | ||
587 | +#endif // CUPS_VERSION_MAJOR > 2 | ||
588 | + | ||
589 | + while (*text && *text != '\n') | ||
590 | + { | ||
591 | + // Escape ":" and "<"... | ||
592 | + if (*text == ':' || *text == '<') | ||
593 | + cupsFilePrintf(fp, "<%02X>", *text); | ||
594 | + else | ||
595 | + cupsFilePutChar(fp, *text); | ||
596 | + | ||
597 | + text ++; | ||
598 | + } | ||
599 | + cupsFilePuts(fp, ": \"\"\n"); | ||
600 | +} | ||
diff --git a/meta-oe/recipes-printing/cups/libppd_2.0.0.bb b/meta-oe/recipes-printing/cups/libppd_2.0.0.bb index 99b1f6e730..f1cf25901e 100644 --- a/meta-oe/recipes-printing/cups/libppd_2.0.0.bb +++ b/meta-oe/recipes-printing/cups/libppd_2.0.0.bb | |||
@@ -5,7 +5,10 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=c1fca671047153ce6825c4ab06f2ab49" | |||
5 | 5 | ||
6 | DEPENDS = "libcupsfilters" | 6 | DEPENDS = "libcupsfilters" |
7 | 7 | ||
8 | SRC_URI = "https://github.com/OpenPrinting/${BPN}/releases/download/${PV}/${BP}.tar.xz" | 8 | SRC_URI = " \ |
9 | https://github.com/OpenPrinting/${BPN}/releases/download/${PV}/${BP}.tar.xz \ | ||
10 | file://0001-CVE-2024-47175.patch \ | ||
11 | " | ||
9 | SRC_URI[sha256sum] = "882d3c659a336e91559de8f3c76fc26197fe6e5539d9b484a596e29a5a4e0bc8" | 12 | SRC_URI[sha256sum] = "882d3c659a336e91559de8f3c76fc26197fe6e5539d9b484a596e29a5a4e0bc8" |
10 | 13 | ||
11 | inherit autotools gettext pkgconfig github-releases | 14 | inherit autotools gettext pkgconfig github-releases |