Blob Blame History Raw
commit 49fa4983f25b64ec29d548ffa3b9782426007df3
Author: Michael Sweet <michael.r.sweet@gmail.com>
Date:   Mon Oct 23 16:23:43 2017 -0400

    DBUS notifications could crash the scheduler (Issue #5143)
    
    - scheduler/ipp.c: Make sure requesting-user-name string is valid UTF-8.

diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index e6743cdcb..5cf980ab3 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -1597,6 +1597,16 @@ add_job(cupsd_client_t  *con,		/* I - Client connection */
     return (NULL);
   }
 
+  attr = ippFindAttribute(con->request, "requesting-user-name", IPP_TAG_NAME);
+
+  if (attr && !ippValidateAttribute(attr))
+  {
+    send_ipp_status(con, IPP_ATTRIBUTES, _("Bad requesting-user-name value: %s"), cupsLastErrorString());
+    if ((attr = ippCopyAttribute(con->response, attr, 0)) != NULL)
+      attr->group_tag = IPP_TAG_UNSUPPORTED_GROUP;
+    return (NULL);
+  }
+
   if ((job = cupsdAddJob(priority, printer->name)) == NULL)
   {
     send_ipp_status(con, IPP_INTERNAL_ERROR,
@@ -1615,8 +1625,6 @@ add_job(cupsd_client_t  *con,		/* I - Client connection */
   add_job_uuid(job);
   apply_printer_defaults(printer, job);
 
-  attr = ippFindAttribute(job->attrs, "requesting-user-name", IPP_TAG_NAME);
-
   if (con->username[0])
   {
     cupsdSetString(&job->username, con->username);