|
|
3635cf |
From 2c030c7a06e0c2b8227c7e85f5c58dfb339731d0 Mon Sep 17 00:00:00 2001
|
|
|
3635cf |
From: Michael R Sweet <michael.r.sweet@gmail.com>
|
|
|
3635cf |
Date: Thu, 15 Aug 2019 14:06:47 -0400
|
|
|
3635cf |
Subject: [PATCH] Multiple security/disclosure issues:
|
|
|
3635cf |
|
|
|
3635cf |
- CVE-2019-8696 and CVE-2019-8675: Fixed SNMP buffer overflows (rdar://51685251)
|
|
|
3635cf |
- Fixed IPP buffer overflow (rdar://50035411)
|
|
|
3635cf |
- Fixed memory disclosure issue in the scheduler (rdar://51373853)
|
|
|
3635cf |
- Fixed DoS issues in the scheduler (rdar://51373929)
|
|
|
3635cf |
|
|
|
3635cf |
diff --git a/cups/http.c b/cups/http.c
|
|
|
3635cf |
index 266a15791..fbb1bf13c 100644
|
|
|
3635cf |
--- a/cups/http.c
|
|
|
3635cf |
+++ b/cups/http.c
|
|
|
3635cf |
@@ -1860,7 +1860,7 @@ httpPrintf(http_t *http, /* I - HTTP connection */
|
|
|
3635cf |
...) /* I - Additional args as needed */
|
|
|
3635cf |
{
|
|
|
3635cf |
ssize_t bytes; /* Number of bytes to write */
|
|
|
3635cf |
- char buf[16384]; /* Buffer for formatted string */
|
|
|
3635cf |
+ char buf[65536]; /* Buffer for formatted string */
|
|
|
3635cf |
va_list ap; /* Variable argument pointer */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
@@ -1872,7 +1872,12 @@ httpPrintf(http_t *http, /* I - HTTP connection */
|
|
|
3635cf |
|
|
|
3635cf |
DEBUG_printf(("3httpPrintf: (" CUPS_LLFMT " bytes) %s", CUPS_LLCAST bytes, buf));
|
|
|
3635cf |
|
|
|
3635cf |
- if (http->data_encoding == HTTP_ENCODING_FIELDS)
|
|
|
3635cf |
+ if (bytes > (ssize_t)(sizeof(buf) - 1))
|
|
|
3635cf |
+ {
|
|
|
3635cf |
+ http->error = ENOMEM;
|
|
|
3635cf |
+ return (-1);
|
|
|
3635cf |
+ }
|
|
|
3635cf |
+ else if (http->data_encoding == HTTP_ENCODING_FIELDS)
|
|
|
3635cf |
return ((int)httpWrite2(http, buf, (size_t)bytes));
|
|
|
3635cf |
else
|
|
|
3635cf |
{
|
|
|
3635cf |
diff --git a/cups/ipp.c b/cups/ipp.c
|
|
|
3635cf |
index 6fae52a00..1bd59cef1 100644
|
|
|
3635cf |
--- a/cups/ipp.c
|
|
|
3635cf |
+++ b/cups/ipp.c
|
|
|
3635cf |
@@ -4550,9 +4550,7 @@ ippSetValueTag(
|
|
|
3635cf |
break;
|
|
|
3635cf |
|
|
|
3635cf |
case IPP_TAG_NAME :
|
|
|
3635cf |
- if (temp_tag != IPP_TAG_KEYWORD && temp_tag != IPP_TAG_URI &&
|
|
|
3635cf |
- temp_tag != IPP_TAG_URISCHEME && temp_tag != IPP_TAG_LANGUAGE &&
|
|
|
3635cf |
- temp_tag != IPP_TAG_MIMETYPE)
|
|
|
3635cf |
+ if (temp_tag != IPP_TAG_KEYWORD)
|
|
|
3635cf |
return (0);
|
|
|
3635cf |
|
|
|
3635cf |
(*attr)->value_tag = (ipp_tag_t)(IPP_TAG_NAME | ((*attr)->value_tag & IPP_TAG_CUPS_CONST));
|
|
|
3635cf |
@@ -4560,10 +4558,7 @@ ippSetValueTag(
|
|
|
3635cf |
|
|
|
3635cf |
case IPP_TAG_NAMELANG :
|
|
|
3635cf |
case IPP_TAG_TEXTLANG :
|
|
|
3635cf |
- if (value_tag == IPP_TAG_NAMELANG &&
|
|
|
3635cf |
- (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD &&
|
|
|
3635cf |
- temp_tag != IPP_TAG_URI && temp_tag != IPP_TAG_URISCHEME &&
|
|
|
3635cf |
- temp_tag != IPP_TAG_LANGUAGE && temp_tag != IPP_TAG_MIMETYPE))
|
|
|
3635cf |
+ if (value_tag == IPP_TAG_NAMELANG && (temp_tag != IPP_TAG_NAME && temp_tag != IPP_TAG_KEYWORD))
|
|
|
3635cf |
return (0);
|
|
|
3635cf |
|
|
|
3635cf |
if (value_tag == IPP_TAG_TEXTLANG && temp_tag != IPP_TAG_TEXT)
|
|
|
3635cf |
diff --git a/cups/snmp.c b/cups/snmp.c
|
|
|
3635cf |
index 5cefee454..1d9da01f2 100644
|
|
|
3635cf |
--- a/cups/snmp.c
|
|
|
3635cf |
+++ b/cups/snmp.c
|
|
|
3635cf |
@@ -1233,6 +1233,9 @@ asn1_get_integer(
|
|
|
3635cf |
int value; /* Integer value */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (0);
|
|
|
3635cf |
+
|
|
|
3635cf |
if (length > sizeof(int))
|
|
|
3635cf |
{
|
|
|
3635cf |
(*buffer) += length;
|
|
|
3635cf |
@@ -1259,6 +1262,9 @@ asn1_get_length(unsigned char **buffer, /* IO - Pointer in buffer */
|
|
|
3635cf |
unsigned length; /* Length */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (0);
|
|
|
3635cf |
+
|
|
|
3635cf |
length = **buffer;
|
|
|
3635cf |
(*buffer) ++;
|
|
|
3635cf |
|
|
|
3635cf |
@@ -1301,6 +1307,9 @@ asn1_get_oid(
|
|
|
3635cf |
int number; /* OID number */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (0);
|
|
|
3635cf |
+
|
|
|
3635cf |
valend = *buffer + length;
|
|
|
3635cf |
oidptr = oid;
|
|
|
3635cf |
oidend = oid + oidsize - 1;
|
|
|
3635cf |
@@ -1349,9 +1358,12 @@ asn1_get_packed(
|
|
|
3635cf |
int value; /* Value */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (0);
|
|
|
3635cf |
+
|
|
|
3635cf |
value = 0;
|
|
|
3635cf |
|
|
|
3635cf |
- while ((**buffer & 128) && *buffer < bufend)
|
|
|
3635cf |
+ while (*buffer < bufend && (**buffer & 128))
|
|
|
3635cf |
{
|
|
|
3635cf |
value = (value << 7) | (**buffer & 127);
|
|
|
3635cf |
(*buffer) ++;
|
|
|
3635cf |
@@ -1379,6 +1391,9 @@ asn1_get_string(
|
|
|
3635cf |
char *string, /* I - String buffer */
|
|
|
3635cf |
size_t strsize) /* I - String buffer size */
|
|
|
3635cf |
{
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (NULL);
|
|
|
3635cf |
+
|
|
|
3635cf |
if (length > (unsigned)(bufend - *buffer))
|
|
|
3635cf |
length = (unsigned)(bufend - *buffer);
|
|
|
3635cf |
|
|
|
3635cf |
@@ -1421,6 +1436,9 @@ asn1_get_type(unsigned char **buffer, /* IO - Pointer in buffer */
|
|
|
3635cf |
int type; /* Type */
|
|
|
3635cf |
|
|
|
3635cf |
|
|
|
3635cf |
+ if (*buffer >= bufend)
|
|
|
3635cf |
+ return (0);
|
|
|
3635cf |
+
|
|
|
3635cf |
type = **buffer;
|
|
|
3635cf |
(*buffer) ++;
|
|
|
3635cf |
|
|
|
3635cf |
diff --git a/scheduler/client.c b/scheduler/client.c
|
|
|
3635cf |
index 923a6e67a..f693e7c49 100644
|
|
|
3635cf |
--- a/scheduler/client.c
|
|
|
3635cf |
+++ b/scheduler/client.c
|
|
|
3635cf |
@@ -564,6 +564,17 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
|
|
|
3635cf |
|
|
|
3635cf |
cupsdLogClient(con, CUPSD_LOG_DEBUG2, "cupsdReadClient: error=%d, used=%d, state=%s, data_encoding=HTTP_ENCODING_%s, data_remaining=" CUPS_LLFMT ", request=%p(%s), file=%d", httpError(con->http), (int)httpGetReady(con->http), httpStateString(httpGetState(con->http)), httpIsChunked(con->http) ? "CHUNKED" : "LENGTH", CUPS_LLCAST httpGetRemaining(con->http), con->request, con->request ? ippStateString(ippGetState(con->request)) : "", con->file);
|
|
|
3635cf |
|
|
|
3635cf |
+ if (httpError(con->http) == EPIPE && !httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
|
|
|
3635cf |
+ {
|
|
|
3635cf |
+ /*
|
|
|
3635cf |
+ * Connection closed...
|
|
|
3635cf |
+ */
|
|
|
3635cf |
+
|
|
|
3635cf |
+ cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on EOF.");
|
|
|
3635cf |
+ cupsdCloseClient(con);
|
|
|
3635cf |
+ return;
|
|
|
3635cf |
+ }
|
|
|
3635cf |
+
|
|
|
3635cf |
if (httpGetState(con->http) == HTTP_STATE_GET_SEND ||
|
|
|
3635cf |
httpGetState(con->http) == HTTP_STATE_POST_SEND ||
|
|
|
3635cf |
httpGetState(con->http) == HTTP_STATE_STATUS)
|
|
|
3635cf |
@@ -573,17 +584,6 @@ cupsdReadClient(cupsd_client_t *con) /* I - Client to read from */
|
|
|
3635cf |
* connection and we need to shut it down...
|
|
|
3635cf |
*/
|
|
|
3635cf |
|
|
|
3635cf |
- if (!httpGetReady(con->http) && recv(httpGetFd(con->http), buf, 1, MSG_PEEK) < 1)
|
|
|
3635cf |
- {
|
|
|
3635cf |
- /*
|
|
|
3635cf |
- * Connection closed...
|
|
|
3635cf |
- */
|
|
|
3635cf |
-
|
|
|
3635cf |
- cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on EOF.");
|
|
|
3635cf |
- cupsdCloseClient(con);
|
|
|
3635cf |
- return;
|
|
|
3635cf |
- }
|
|
|
3635cf |
-
|
|
|
3635cf |
cupsdLogClient(con, CUPSD_LOG_DEBUG, "Closing on unexpected HTTP read state %s.", httpStateString(httpGetState(con->http)));
|
|
|
3635cf |
cupsdCloseClient(con);
|
|
|
3635cf |
return;
|
|
|
3635cf |
@@ -1950,6 +1950,7 @@ cupsdSendError(cupsd_client_t *con, /* I - Connection */
|
|
|
3635cf |
strlcpy(location, httpGetField(con->http, HTTP_FIELD_LOCATION), sizeof(location));
|
|
|
3635cf |
|
|
|
3635cf |
httpClearFields(con->http);
|
|
|
3635cf |
+ httpClearCookie(con->http);
|
|
|
3635cf |
|
|
|
3635cf |
httpSetField(con->http, HTTP_FIELD_LOCATION, location);
|
|
|
3635cf |
|
|
|
3635cf |
--
|
|
|
3635cf |
2.21.0
|
|
|
3635cf |
|