cups-filters/0001-cfGetPrinterAttributes5-Validate-response-attributes.patch

68 lines
2.3 KiB
Diff

diff --git a/backend/implicitclass.c b/backend/implicitclass.c
index 1593191..3dad471 100644
--- a/backend/implicitclass.c
+++ b/backend/implicitclass.c
@@ -126,6 +126,14 @@ main(int argc, /* I - Number of command-line args */
if ((response = cupsDoRequest(CUPS_HTTP_DEFAULT, request, "/")) ==
NULL)
goto failed;
+
+ if (response && !ippValidateAttributes(response))
+ {
+ fprintf(stderr, "ERROR: The printer %s contains invalid attributes.", queue_name);
+ ippDelete(response);
+ return (CUPS_BACKEND_STOP);
+ }
+
for (attr = ippFirstAttribute(response); attr != NULL;
attr = ippNextAttribute(response)) {
while (attr != NULL && ippGetGroupTag(attr) != IPP_TAG_PRINTER)
diff --git a/utils/cups-browsed.c b/utils/cups-browsed.c
index 2b30c63..d65fecf 100644
--- a/utils/cups-browsed.c
+++ b/utils/cups-browsed.c
@@ -2639,6 +2639,13 @@ record_printer_options(const char *printer) {
uri);
response = cupsDoRequest(conn, request, resource);
+ if (response && !ippValidateAttributes(response))
+ {
+ fprintf(stderr, "The printer %s contains invalid attributes.", printer);
+ ippDelete(response);
+ return -1;
+ }
+
/* Write all supported printer attributes */
if (response) {
attr = ippFirstAttribute(response);
@@ -3576,6 +3583,12 @@ create_remote_printer_entry (const char *queue_name,
NULL, pattrs);
response = cupsDoRequest(http_printer, request, resource);
+ if (response && !ippValidateAttributes(response))
+ {
+ fprintf(stderr, "The printer %s contains invalid attributes.", p->queue_name);
+ goto fail;
+ }
+
/* Log all printer attributes for debugging */
if (debug_stderr || debug_logfile) {
debug_printf("Full list of IPP attributes (get-printer-attributes) for printer %s:\n",
diff --git a/utils/driverless.c b/utils/driverless.c
index fe61e58..0360bff 100644
--- a/utils/driverless.c
+++ b/utils/driverless.c
@@ -513,6 +513,12 @@ generate_ppd (const char *uri)
NULL, pattrs);
response = cupsDoRequest(http, request, resource);
+ if (response && !ippValidateAttributes(response))
+ {
+ fprintf(stderr, "ERROR: The printer provides invalid attributes, skipping.");
+ goto fail;
+ }
+
/* Log all printer attributes for debugging */
if (debug) {
attr = ippFirstAttribute(response);