summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDidier Raboud <odyx@debian.org>2018-06-08 15:10:26 +0200
committerDidier Raboud <odyx@debian.org>2018-06-08 15:10:26 +0200
commit58a0b0902e9df38a768bc84a2eb6f97882c6f319 (patch)
tree08ddfde910c9e91d62e043107f3ae661888cb4fa
parentf2f9904758327e965855c5a43ce091e270cd1f1f (diff)
Revert "Mirror validation changes from 2.2 branch."
This reverts commit 4cadd6202fbcfc6bcb18c7bada4c40af4e8d736b. Fixes FTBFS on 2.2.8+, see https://github.com/apple/cups/issues/5322
-rw-r--r--cups/ipp.c25
-rw-r--r--cups/testhttp.c10
-rw-r--r--scheduler/ipp.c164
3 files changed, 97 insertions, 102 deletions
diff --git a/cups/ipp.c b/cups/ipp.c
index 714c2e522..179764104 100644
--- a/cups/ipp.c
+++ b/cups/ipp.c
@@ -1,11 +1,10 @@
/*
* Internet Printing Protocol functions for CUPS.
*
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
+ * Copyright 2007-2017 by Apple Inc.
+ * Copyright 1997-2007 by Easy Software Products, all rights reserved.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
@@ -5025,16 +5024,9 @@ ippValidateAttribute(
}
else if (*ptr & 0x80)
break;
- else if ((*ptr < ' ' && *ptr != '\n' && *ptr != '\r' && *ptr != '\t') || *ptr == 0x7f)
- break;
}
- if (*ptr < ' ' || *ptr == 0x7f)
- {
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad control character (PWG 5100.14 section 8.3)."), attr->name, attr->values[i].string.text);
- return (0);
- }
- else if (*ptr)
+ if (*ptr)
{
ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad text value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.2)."), attr->name, attr->values[i].string.text);
return (0);
@@ -5083,16 +5075,9 @@ ippValidateAttribute(
}
else if (*ptr & 0x80)
break;
- else if (*ptr < ' ' || *ptr == 0x7f)
- break;
}
- if (*ptr < ' ' || *ptr == 0x7f)
- {
- ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad control character (PWG 5100.14 section 8.1)."), attr->name, attr->values[i].string.text);
- return (0);
- }
- else if (*ptr)
+ if (*ptr)
{
ipp_set_error(IPP_STATUS_ERROR_BAD_REQUEST, _("\"%s\": Bad name value \"%s\" - bad UTF-8 sequence (RFC 8011 section 5.1.3)."), attr->name, attr->values[i].string.text);
return (0);
diff --git a/cups/testhttp.c b/cups/testhttp.c
index bc77b0236..65d862def 100644
--- a/cups/testhttp.c
+++ b/cups/testhttp.c
@@ -1,11 +1,10 @@
/*
* HTTP test program for CUPS.
*
- * Copyright © 2007-2018 by Apple Inc.
- * Copyright © 1997-2006 by Easy Software Products.
+ * Copyright 2007-2014 by Apple Inc.
+ * Copyright 1997-2006 by Easy Software Products.
*
- * Licensed under Apache License v2.0. See the file "LICENSE" for more
- * information.
+ * Licensed under Apache License v2.0. See the file "LICENSE" for more information.
*/
/*
@@ -181,9 +180,6 @@ static uri_test_t uri_tests[] = /* URI test data */
HTTP_URI_CODING_MOST },
/* Bad resource */
- { HTTP_URI_STATUS_BAD_RESOURCE, "mailto:\r\nbla",
- "mailto", "", "", "", 0, 0,
- HTTP_URI_CODING_MOST },
{ HTTP_URI_STATUS_BAD_RESOURCE, "http://server/index.html%",
"http", "", "server", "", 80, 0,
HTTP_URI_CODING_MOST },
diff --git a/scheduler/ipp.c b/scheduler/ipp.c
index 89058d285..859250ba8 100644
--- a/scheduler/ipp.c
+++ b/scheduler/ipp.c
@@ -5848,26 +5848,7 @@ create_subscriptions(
}
if (recipient)
- {
cupsdLogMessage(CUPSD_LOG_DEBUG, "recipient=\"%s\"", recipient);
-
-
- if (!strncmp(recipient, "mailto:", 7) && user_data)
- {
- char temp[64]; /* Temporary string */
-
- memcpy(temp, user_data->values[0].unknown.data, user_data->values[0].unknown.length);
- temp[user_data->values[0].unknown.length] = '\0';
-
- if (httpSeparateURI(HTTP_URI_CODING_ALL, temp, scheme, sizeof(scheme), userpass, sizeof(userpass), host, sizeof(host), &port, resource, sizeof(resource)) < HTTP_URI_OK)
- {
- send_ipp_status(con, IPP_NOT_POSSIBLE, _("Bad notify-user-data \"%s\"."), temp);
- ippAddInteger(con->response, IPP_TAG_SUBSCRIPTION, IPP_TAG_ENUM, "notify-status-code", IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES);
- return;
- }
- }
- }
-
if (pullmethod)
cupsdLogMessage(CUPSD_LOG_DEBUG, "pullmethod=\"%s\"", pullmethod);
cupsdLogMessage(CUPSD_LOG_DEBUG, "notify-lease-duration=%d", lease);
@@ -7978,16 +7959,13 @@ hold_job(cupsd_client_t *con, /* I - Client connection */
* Hold the job and return...
*/
- if ((attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_ZERO)) != NULL)
- {
- if ((ippGetValueTag(attr) != IPP_TAG_KEYWORD && ippGetValueTag(attr) != IPP_TAG_NAME && ippGetValueTag(attr) != IPP_TAG_NAMELANG) || ippGetCount(attr) != 1 || !ippValidateAttribute(attr))
- {
- send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value."));
- ippCopyAttribute(con->response, attr, 0);
- return;
- }
+ if ((attr = ippFindAttribute(con->request, "job-hold-until",
+ IPP_TAG_KEYWORD)) == NULL)
+ attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_NAME);
- when = ippGetString(attr, 0, NULL);
+ if (attr)
+ {
+ when = attr->values[0].string.text;
cupsdAddEvent(CUPSD_EVENT_JOB_CONFIG_CHANGED, cupsdFindDest(job->dest), job,
"Job job-hold-until value changed by user.");
@@ -10351,39 +10329,7 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */
continue;
}
- if (!ippValidateAttribute(attr))
- {
- send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Bad '%s' value."), attr->name);
- ippCopyAttribute(con->response, attr, 0);
- return;
- }
-
- if (!strcmp(attr->name, "job-hold-until"))
- {
- const char *when = ippGetString(attr, 0, NULL);
- /* job-hold-until value */
-
- if ((ippGetValueTag(attr) != IPP_TAG_KEYWORD && ippGetValueTag(attr) != IPP_TAG_NAME && ippGetValueTag(attr) != IPP_TAG_NAMELANG) || ippGetCount(attr) != 1)
- {
- send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value."));
- ippCopyAttribute(con->response, attr, 0);
- return;
- }
-
- cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-hold-until to %s", when);
- cupsdSetJobHoldUntil(job, when, 0);
-
- if (!strcmp(when, "no-hold"))
- {
- cupsdReleaseJob(job);
- check_jobs = 1;
- }
- else
- cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT, "Job held by \"%s\".", username);
-
- event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE;
- }
- else if (!strcmp(attr->name, "job-priority"))
+ if (!strcmp(attr->name, "job-priority"))
{
/*
* Change the job priority...
@@ -10503,6 +10449,28 @@ set_job_attrs(cupsd_client_t *con, /* I - Client connection */
*/
ippCopyAttribute(job->attrs, attr, 0);
+
+ /*
+ * See if the job-name or job-hold-until is being changed.
+ */
+
+ if (!strcmp(attr->name, "job-hold-until"))
+ {
+ cupsdLogJob(job, CUPSD_LOG_DEBUG, "Setting job-hold-until to %s",
+ attr->values[0].string.text);
+ cupsdSetJobHoldUntil(job, attr->values[0].string.text, 0);
+
+ if (!strcmp(attr->values[0].string.text, "no-hold"))
+ {
+ cupsdReleaseJob(job);
+ check_jobs = 1;
+ }
+ else
+ cupsdSetJobState(job, IPP_JOB_HELD, CUPSD_JOB_DEFAULT,
+ "Job held by \"%s\".", username);
+
+ event |= CUPSD_EVENT_JOB_CONFIG_CHANGED | CUPSD_EVENT_JOB_STATE;
+ }
}
else if (attr->value_tag == IPP_TAG_DELETEATTR)
{
@@ -11321,34 +11289,80 @@ validate_job(cupsd_client_t *con, /* I - Client connection */
}
/*
- * Is the job-hold-until value valid?
- */
-
- if ((attr = ippFindAttribute(con->request, "job-hold-until", IPP_TAG_ZERO)) != NULL && ((ippGetValueTag(attr) != IPP_TAG_KEYWORD && ippGetValueTag(attr) != IPP_TAG_NAME && ippGetValueTag(attr) != IPP_TAG_NAMELANG) || ippGetCount(attr) != 1 || !ippValidateAttribute(attr)))
- {
- send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-hold-until' value."));
- ippCopyAttribute(con->response, attr, 0);
- return;
- }
-
- /*
* Is the job-name valid?
*/
if ((name = ippFindAttribute(con->request, "job-name", IPP_TAG_ZERO)) != NULL)
{
+ int bad_name = 0; /* Is the job-name value bad? */
+
if ((name->value_tag != IPP_TAG_NAME && name->value_tag != IPP_TAG_NAMELANG) ||
- name->num_values != 1 || !ippValidateAttribute(name))
+ name->num_values != 1)
+ {
+ bad_name = 1;
+ }
+ else
+ {
+ /*
+ * Validate that job-name conforms to RFC 5198 (Network Unicode) and
+ * IPP Everywhere requirements for "name" values...
+ */
+
+ const unsigned char *nameptr; /* Pointer into "job-name" attribute */
+
+ for (nameptr = (unsigned char *)name->values[0].string.text;
+ *nameptr;
+ nameptr ++)
+ {
+ if (*nameptr < ' ' && *nameptr != '\t')
+ break;
+ else if (*nameptr == 0x7f)
+ break;
+ else if ((*nameptr & 0xe0) == 0xc0)
+ {
+ if ((nameptr[1] & 0xc0) != 0x80)
+ break;
+
+ nameptr ++;
+ }
+ else if ((*nameptr & 0xf0) == 0xe0)
+ {
+ if ((nameptr[1] & 0xc0) != 0x80 ||
+ (nameptr[2] & 0xc0) != 0x80)
+ break;
+
+ nameptr += 2;
+ }
+ else if ((*nameptr & 0xf8) == 0xf0)
+ {
+ if ((nameptr[1] & 0xc0) != 0x80 ||
+ (nameptr[2] & 0xc0) != 0x80 ||
+ (nameptr[3] & 0xc0) != 0x80)
+ break;
+
+ nameptr += 3;
+ }
+ else if (*nameptr & 0x80)
+ break;
+ }
+
+ if (*nameptr)
+ bad_name = 1;
+ }
+
+ if (bad_name)
{
if (StrictConformance)
{
- send_ipp_status(con, IPP_STATUS_ERROR_ATTRIBUTES_OR_VALUES, _("Unsupported 'job-name' value."));
+ send_ipp_status(con, IPP_ATTRIBUTES,
+ _("Unsupported 'job-name' value."));
ippCopyAttribute(con->response, name, 0);
return;
}
else
{
- cupsdLogMessage(CUPSD_LOG_WARN, "Unsupported 'job-name' value, deleting from request.");
+ cupsdLogMessage(CUPSD_LOG_WARN,
+ "Unsupported 'job-name' value, deleting from request.");
ippDeleteAttribute(con->request, name);
}
}