From: Michael R Sweet Date: Sun, 11 Feb 2024 14:23:13 +0000 (-0500) Subject: Return HTTP status 404 for non-existing classes and printers (Issue #423) X-Git-Tag: v2.4.8~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9a9f9b380f68c39f2e6039ac7ee543e328b2fdab;p=thirdparty%2Fcups.git Return HTTP status 404 for non-existing classes and printers (Issue #423) --- diff --git a/CHANGES.md b/CHANGES.md index e4ab5ec061..e21d0b53ac 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,15 +4,17 @@ CHANGES - OpenPrinting CUPS 2.4.8 - TBA Changes in CUPS v2.4.8 (TBA) ---------------------------- -- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644) -- Really backport fix for Issue #742 -- Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751) -- Fixed memory leak when unloading a job (Issue #813) -- Fixed memory leak when creating color profiles (Issue #815) - Added warning if the device has to be asked for 'all,media-col-database' separately (Issue #829) - Added new value for 'lpstat' option '-W' - successfull - for getting successfully printed jobs (Issue #830) +- Raised `cups_enum_dests()` timeout for listing available IPP printers (Issue #751) +- Fixed the web interface not showing an error for a non-existent printer + (Issue #423) +- Fixed printing of jobs with job name longer than 255 chars on older printers (Issue #644) +- Really backport fix for Issue #742 +- Fixed memory leak when unloading a job (Issue #813) +- Fixed memory leak when creating color profiles (Issue #815) - Fixed crash in `scan_ps()` if incoming argument is NULL (Issue #831) - Fixed setting job state reasons for successful jobs (Issue #832) - Fixed infinite loop in IPP backend if hostname is IP address with Kerberos (Issue #838) diff --git a/scheduler/client.c b/scheduler/client.c index 5791a7a8ce..a2f53744ce 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -1130,8 +1130,19 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ } else if (!strncmp(con->uri, "/classes", 8)) { + if (strlen(con->uri) > 9 && !cupsdFindClass(con->uri + 9)) + { + if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + + break; + } + cupsdSetStringf(&con->command, "%s/cgi-bin/classes.cgi", ServerBin); - if (con->uri[8] && con->uri[9]) + if (con->uri[8] && con->uri[9]) cupsdSetString(&con->options, con->uri + 8); else cupsdSetString(&con->options, NULL); @@ -1146,6 +1157,17 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */ } else if (!strncmp(con->uri, "/printers", 9)) { + if (strlen(con->uri) > 10 && !cupsdFindPrinter(con->uri + 10)) + { + if (!cupsdSendError(con, HTTP_STATUS_NOT_FOUND, CUPSD_AUTH_NONE)) + { + cupsdCloseClient(con); + return; + } + + break; + } + cupsdSetStringf(&con->command, "%s/cgi-bin/printers.cgi", ServerBin); if (con->uri[9] && con->uri[10]) cupsdSetString(&con->options, con->uri + 9);