Validate external responses

Resolves: RHEL-60325
This commit is contained in:
Zdenek Dohnal 2024-09-27 06:48:19 +02:00
parent 60348c5746
commit 467ddbed71

View File

@ -1,41 +1,8 @@
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
index 2b30c63..a6d6fd2 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,
@@ -3576,6 +3576,12 @@ create_remote_printer_entry (const char *queue_name,
NULL, pattrs);
response = cupsDoRequest(http_printer, request, resource);